MediaWiki master
UserIdentityUtils.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\User;
4
6
14 private TempUserConfig $tempUserConfig;
15
21 public function __construct( TempUserConfig $tempUserConfig ) {
22 $this->tempUserConfig = $tempUserConfig;
23 }
24
31 public function isTemp( UserIdentity $user ) {
32 return $this->tempUserConfig->isTempName( $user->getName() );
33 }
34
41 public function isNamed( UserIdentity $user ) {
42 return $user->isRegistered()
43 && !$this->tempUserConfig->isTempName( $user->getName() );
44 }
45
54 public function getShortUserTypeInternal( UserIdentity $user ): string {
55 if ( !$user->isRegistered() ) {
56 return 'anon';
57 }
58 return $this->isTemp( $user ) ? 'temp' : 'named';
59 }
60}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
Convenience functions for interpreting UserIdentity objects using additional services or config.
isNamed(UserIdentity $user)
Is the user a normal non-temporary registered user?
__construct(TempUserConfig $tempUserConfig)
getShortUserTypeInternal(UserIdentity $user)
Get user identity type, used for internal logic like tracking statistics per account type.
isTemp(UserIdentity $user)
Is the user a temporary user?
Interface for temporary user creation config and name matching.
Interface for objects representing user identity.
isRegistered()
This must be equivalent to getId() != 0 and is provided for code readability.