mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-14 11:16:16 +00:00
c76761eff3
Bug: T305667 Change-Id: I5a7846a0fc383bddbf6511d6ba73c8be7d7760c7
29 lines
774 B
PHP
29 lines
774 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Push;
|
|
|
|
use CentralIdLookup;
|
|
use MediaWiki\MediaWikiServices;
|
|
use MediaWiki\User\UserIdentity;
|
|
|
|
class Utils {
|
|
|
|
/**
|
|
* Attempt to get a unique ID for the specified user, accounting for installations both with
|
|
* and without CentralAuth: Return the user's central ID, if available. If there is no central
|
|
* user associated with the local user (i.e., centralIdFromLocalUser returns 0), fall back to
|
|
* returning the local user ID.
|
|
* @param UserIdentity $user
|
|
* @return int
|
|
*/
|
|
public static function getPushUserId( UserIdentity $user ): int {
|
|
return MediaWikiServices::getInstance()
|
|
->getCentralIdLookup()
|
|
->centralIdFromLocalUser(
|
|
$user,
|
|
CentralIdLookup::AUDIENCE_RAW
|
|
) ?: $user->getId();
|
|
}
|
|
|
|
}
|