MediaWiki REL1_37
MediaWiki\User\UserIdentityValue Class Reference

Value object representing a user's identity. More...

Inheritance diagram for MediaWiki\User\UserIdentityValue:
Collaboration diagram for MediaWiki\User\UserIdentityValue:

Public Member Functions

 __construct (int $id, string $name, $wikiId=self::LOCAL)
 
 __toString ()
 
 equals (?UserIdentity $user)
 
 getActorId ( $wikiId=self::LOCAL)
 
 getId ( $wikiId=self::LOCAL)
 The numerical user ID provided to the constructor.
 
 getName ()
 
 getWikiId ()
 Get the ID of the wiki this UserIdentity belongs to.
 
 isRegistered ()
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Static Public Member Functions

static newAnonymous (string $name, $wikiId=self::LOCAL)
 Create UserIdentity for an anonymous user.
 
static newExternal (string $prefix, string $name, $wikiId=self::LOCAL)
 Create UserIdentity for an external user with $prefix and $name.
 
static newRegistered (int $userId, string $name, $wikiId=self::LOCAL)
 Create UserIdentity for a registered user.
 

Private Attributes

int $id
 
string $name
 
bool string $wikiId
 

Detailed Description

Value object representing a user's identity.

@newable

Since
1.31

Definition at line 35 of file UserIdentityValue.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\UserIdentityValue::__construct ( int  $id,
string  $name,
  $wikiId = self::LOCAL 
)
Stability: stable
to call
Note
Signature in 1.35 was: ( $id, $name, $actor ). This is still supported for backwards compatibility until 1.37. $actor is ignored.
Parameters
int$iduser ID
string$nameuser name
string | false$wikiIdwiki ID or self::LOCAL for the local wiki

Definition at line 61 of file UserIdentityValue.php.

References $args, MediaWiki\User\UserIdentityValue\$id, MediaWiki\User\UserIdentityValue\$name, MediaWiki\User\UserIdentityValue\$wikiId, and wfDeprecatedMsg().

Member Function Documentation

◆ __toString()

MediaWiki\User\UserIdentityValue::__toString ( )

Definition at line 192 of file UserIdentityValue.php.

◆ equals()

MediaWiki\User\UserIdentityValue::equals ( ?UserIdentity  $user)
Since
1.32
Parameters
UserIdentity | null$user
Returns
bool

Implements MediaWiki\User\UserIdentity.

Definition at line 173 of file UserIdentityValue.php.

◆ getActorId()

MediaWiki\User\UserIdentityValue::getActorId (   $wikiId = self::LOCAL)
Deprecated:
since 1.36, use ActorNormalization::acquireActorId instead.
Parameters
string | false$wikiId
Returns
int always 0.

Definition at line 162 of file UserIdentityValue.php.

◆ getId()

MediaWiki\User\UserIdentityValue::getId (   $wikiId = self::LOCAL)

The numerical user ID provided to the constructor.

Parameters
string | false$wikiIdThe wiki ID expected by the caller
Returns
int The user ID. May be 0 for anonymous users or for users with no local account.

Implements MediaWiki\User\UserIdentity.

Definition at line 143 of file UserIdentityValue.php.

◆ getName()

MediaWiki\User\UserIdentityValue::getName ( )
Returns
string The user's logical name. May be an IPv4 or IPv6 address for anonymous users.

Implements MediaWiki\User\UserIdentity.

Definition at line 151 of file UserIdentityValue.php.

◆ getWikiId()

MediaWiki\User\UserIdentityValue::getWikiId ( )

Get the ID of the wiki this UserIdentity belongs to.

Since
1.36
See also
RevisionRecord::getWikiId()
Returns
string|false The wiki's logical name or self::LOCAL to indicate the local wiki

Implements MediaWiki\DAO\WikiAwareEntity.

Definition at line 132 of file UserIdentityValue.php.

◆ isRegistered()

MediaWiki\User\UserIdentityValue::isRegistered ( )
Since
1.34
Returns
bool True if user is registered on this wiki, i.e., has a user ID. False if user is anonymous or has no local account (which can happen when importing). This is equivalent to getId() != 0 and is provided for code readability.

Implements MediaWiki\User\UserIdentity.

Definition at line 188 of file UserIdentityValue.php.

◆ newAnonymous()

static MediaWiki\User\UserIdentityValue::newAnonymous ( string  $name,
  $wikiId = self::LOCAL 
)
static

Create UserIdentity for an anonymous user.

Since
1.36
Parameters
string$name
string | false$wikiIdwiki ID or self::LOCAL for the local wiki
Returns
UserIdentityValue

Definition at line 92 of file UserIdentityValue.php.

◆ newExternal()

static MediaWiki\User\UserIdentityValue::newExternal ( string  $prefix,
string  $name,
  $wikiId = self::LOCAL 
)
static

Create UserIdentity for an external user with $prefix and $name.

Since
1.36
Parameters
string$prefix
string$name
string | false$wikiIdwiki ID or self::LOCAL for the local wiki
Returns
UserIdentityValue

Definition at line 119 of file UserIdentityValue.php.

◆ newRegistered()

static MediaWiki\User\UserIdentityValue::newRegistered ( int  $userId,
string  $name,
  $wikiId = self::LOCAL 
)
static

Create UserIdentity for a registered user.

Since
1.36
Parameters
int$userId
string$name
string | false$wikiIdwiki ID or self::LOCAL for the local wiki
Returns
UserIdentityValue

Definition at line 105 of file UserIdentityValue.php.

Member Data Documentation

◆ $id

int MediaWiki\User\UserIdentityValue::$id
private

Definition at line 41 of file UserIdentityValue.php.

Referenced by MediaWiki\User\UserIdentityValue\__construct().

◆ $name

string MediaWiki\User\UserIdentityValue::$name
private

Definition at line 46 of file UserIdentityValue.php.

Referenced by MediaWiki\User\UserIdentityValue\__construct().

◆ $wikiId

bool string MediaWiki\User\UserIdentityValue::$wikiId
private

Definition at line 49 of file UserIdentityValue.php.

Referenced by MediaWiki\User\UserIdentityValue\__construct().


The documentation for this class was generated from the following file: