Inject service LinkBatchFactory into ApiEchoMute

Change-Id: I98c1d2f6b1aa04eb64cef299a6aca475658bdd74
This commit is contained in:
Fomafix 2024-03-17 19:13:44 +00:00
parent 2dd93768c5
commit 73bd6e8ef1
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 ) );
}