MediaWiki  master
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. More...
 
 getName ()
 
 getWikiId ()
 Get the ID of the wiki this UserIdentity belongs to. More...
 
 isRegistered ()
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId(). More...
 

Static Public Member Functions

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

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, MediaWiki\DAO\assertWikiIdParam(), and wfDeprecatedMsg().

Member Function Documentation

◆ __toString()

MediaWiki\User\UserIdentityValue::__toString ( )

Definition at line 192 of file UserIdentityValue.php.

References MediaWiki\User\UserIdentityValue\getName().

◆ 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.

References MediaWiki\User\UserIdentity\getName(), and MediaWiki\User\UserIdentityValue\getName().

◆ 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.

References wfDeprecated().

◆ 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.

References MediaWiki\User\UserIdentityValue\$id, and MediaWiki\DAO\deprecateInvalidCrossWiki().

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

◆ 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.

References MediaWiki\User\UserIdentityValue\$name.

Referenced by MediaWiki\User\UserIdentityValue\__toString(), and MediaWiki\User\UserIdentityValue\equals().

◆ 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.

References MediaWiki\User\UserIdentityValue\$wikiId.

◆ 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.

References MediaWiki\User\UserIdentityValue\getId().

◆ 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.

References MediaWiki\User\UserIdentityValue\$name, and MediaWiki\User\UserIdentityValue\$wikiId.

Referenced by MediaWiki\Block\BlockUtils\parseBlockTarget(), and Wikimedia\ParamValidator\ParamValidator\TypeDef\UserDef\processUser().

◆ 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.37
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.

References MediaWiki\User\UserIdentityValue\$wikiId.

◆ newRegistered()

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

Create UserIdentity for a registered user.

Since
1.37
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.

References MediaWiki\User\UserIdentityValue\$name, and MediaWiki\User\UserIdentityValue\$wikiId.

Member Data Documentation

◆ $id

int MediaWiki\User\UserIdentityValue::$id
private

◆ $name

◆ $wikiId


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