Merge "Inject service LinkBatchFactory into ApiEchoMute"

This commit is contained in:
jenkins-bot 2024-03-17 22:39:16 +00:00 committed by Gerrit Code Review
commit 817dd42561
2 changed files with 9 additions and 2 deletions

View file

@ -40,6 +40,7 @@
"class": "MediaWiki\\Extension\\Notifications\\Api\\ApiEchoMute",
"services": [
"CentralIdLookup",
"LinkBatchFactory",
"UserOptionsManager"
]
}

View file

@ -4,7 +4,7 @@ namespace MediaWiki\Extension\Notifications\Api;
use ApiBase;
use ApiMain;
use MediaWiki\MediaWikiServices;
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\Title\Title;
use MediaWiki\User\CentralId\CentralIdLookup;
use MediaWiki\User\Options\UserOptionsManager;
@ -15,6 +15,9 @@ class ApiEchoMute extends ApiBase {
/** @var CentralIdLookup */
private $centralIdLookup;
/** @var LinkBatchFactory */
private $linkBatchFactory;
/** @var UserOptionsManager */
private $userOptionsManager;
@ -34,17 +37,20 @@ class ApiEchoMute extends ApiBase {
* @param ApiMain $main
* @param string $action
* @param CentralIdLookup $centralIdLookup
* @param LinkBatchFactory $linkBatchFactory
* @param UserOptionsManager $userOptionsManager
*/
public function __construct(
ApiMain $main,
$action,
CentralIdLookup $centralIdLookup,
LinkBatchFactory $linkBatchFactory,
UserOptionsManager $userOptionsManager
) {
parent::__construct( $main, $action );
$this->centralIdLookup = $centralIdLookup;
$this->linkBatchFactory = $linkBatchFactory;
$this->userOptionsManager = $userOptionsManager;
}
@ -97,7 +103,7 @@ class ApiEchoMute extends ApiBase {
private function lookupIds( $names, $type ) {
if ( $type === 'title' ) {
$linkBatch = MediaWikiServices::getInstance()->getLinkBatchFactory()->newLinkBatch();
$linkBatch = $this->linkBatchFactory->newLinkBatch();
foreach ( $names as $name ) {
$linkBatch->addObj( Title::newFromText( $name ) );
}