mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-24 00:13:27 +00:00
Inject service RepoGroup in PageImages
Change-Id: I91d12fe25fbd6ee952d635cd24b5047be8790c80
This commit is contained in:
parent
1f95b141a6
commit
029af825a9
|
@ -37,6 +37,7 @@
|
|||
"main": {
|
||||
"class": "PageImages\\PageImages",
|
||||
"services": [
|
||||
"RepoGroup",
|
||||
"UserOptionsLookup"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -16,6 +16,7 @@ use MediaWiki\Request\FauxRequest;
|
|||
use MediaWiki\Title\Title;
|
||||
use MediaWiki\User\UserOptionsLookup;
|
||||
use OutputPage;
|
||||
use RepoGroup;
|
||||
use Skin;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +59,9 @@ class PageImages implements
|
|||
*/
|
||||
public const PROP_NAME_FREE = 'page_image_free';
|
||||
|
||||
/** @var RepoGroup */
|
||||
private $repoGroup;
|
||||
|
||||
/** @var UserOptionsLookup */
|
||||
private $userOptionsLookup;
|
||||
|
||||
|
@ -68,15 +72,22 @@ class PageImages implements
|
|||
* @return PageImages
|
||||
*/
|
||||
private static function factory() {
|
||||
$services = MediaWikiServices::getInstance();
|
||||
return new self(
|
||||
MediaWikiServices::getInstance()->getUserOptionsLookup()
|
||||
$services->getRepoGroup(),
|
||||
$services->getUserOptionsLookup()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RepoGroup $repoGroup
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
*/
|
||||
public function __construct( UserOptionsLookup $userOptionsLookup ) {
|
||||
public function __construct(
|
||||
RepoGroup $repoGroup,
|
||||
UserOptionsLookup $userOptionsLookup
|
||||
) {
|
||||
$this->repoGroup = $repoGroup;
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
}
|
||||
|
||||
|
@ -149,7 +160,7 @@ class PageImages implements
|
|||
}
|
||||
|
||||
if ( $title->inNamespace( NS_FILE ) ) {
|
||||
return MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
|
||||
return $this->repoGroup->findFile( $title );
|
||||
}
|
||||
|
||||
$pageId = $title->getArticleID();
|
||||
|
@ -174,7 +185,7 @@ class PageImages implements
|
|||
return false;
|
||||
}
|
||||
|
||||
return MediaWikiServices::getInstance()->getRepoGroup()->findFile( $fileName );
|
||||
return $this->repoGroup->findFile( $fileName );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,8 +22,10 @@ use SkinTemplate;
|
|||
class PageImagesTest extends MediaWikiIntegrationTestCase {
|
||||
|
||||
private function newPageImages() {
|
||||
$services = $this->getServiceContainer();
|
||||
return new PageImages(
|
||||
$this->getServiceContainer()->getUserOptionsLookup()
|
||||
$services->getRepoGroup(),
|
||||
$services->getUserOptionsLookup()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue