MediaWiki  master
WatchedItem.php
Go to the documentation of this file.
1 <?php
24 
33 class WatchedItem {
37  private $linkTarget;
38 
42  private $user;
43 
48 
52  private $expiry;
53 
60  public function __construct(
64  ?string $expiry = null
65  ) {
66  $this->user = $user;
67  $this->linkTarget = $linkTarget;
68  $this->notificationTimestamp = $notificationTimestamp;
69  $this->expiry = $expiry;
70  }
71 
76  public function getUser() {
77  return User::newFromIdentity( $this->user );
78  }
79 
83  public function getUserIdentity() {
84  return $this->user;
85  }
86 
90  public function getLinkTarget() {
91  return $this->linkTarget;
92  }
93 
99  public function getNotificationTimestamp() {
101  }
102 
110  public function getExpiry(): ?string {
111  return $this->expiry;
112  }
113 
121  public function isExpired(): bool {
122  if ( null === $this->getExpiry() ) {
123  return false;
124  }
125 
126  $unix = MWTimestamp::convert( TS_UNIX, $this->getExpiry() );
127  return $unix < wfTimestamp();
128  }
129 }
WatchedItem\$notificationTimestamp
null string $notificationTimestamp
the value of the wl_notificationtimestamp field
Definition: WatchedItem.php:47
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1806
User\newFromIdentity
static newFromIdentity(UserIdentity $identity)
Returns a User object corresponding to the given UserIdentity.
Definition: User.php:591
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:32
WatchedItem\$user
UserIdentity $user
Definition: WatchedItem.php:42
WatchedItem\__construct
__construct(UserIdentity $user, LinkTarget $linkTarget, $notificationTimestamp, ?string $expiry=null)
Definition: WatchedItem.php:60
WatchedItem\getUserIdentity
getUserIdentity()
Definition: WatchedItem.php:83
WatchedItem\getUser
getUser()
Definition: WatchedItem.php:76
WatchedItem
Representation of a pair of user and title for watchlist entries.
Definition: WatchedItem.php:33
WatchedItem\getExpiry
getExpiry()
When the watched item will expire.
Definition: WatchedItem.php:110
WatchedItem\getLinkTarget
getLinkTarget()
Definition: WatchedItem.php:90
WatchedItem\isExpired
isExpired()
Has the watched item expired?
Definition: WatchedItem.php:121
WatchedItem\getNotificationTimestamp
getNotificationTimestamp()
Get the notification timestamp of this entry.
Definition: WatchedItem.php:99
WatchedItem\$expiry
string null $expiry
When to automatically unwatch the page.
Definition: WatchedItem.php:52
MediaWiki\Linker\LinkTarget
Definition: LinkTarget.php:26
WatchedItem\$linkTarget
LinkTarget $linkTarget
Definition: WatchedItem.php:37