mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Merge "Use new ResourceLoader namespace"
This commit is contained in:
commit
20ec7ced59
|
@ -15,7 +15,7 @@
|
|||
"license-name": "GPL-2.0-or-later",
|
||||
"type": "parserhook",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.38.0"
|
||||
"MediaWiki": ">= 1.39.0"
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"Cite": [
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Cite\ResourceLoader;
|
||||
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\ResourceLoader\FileModule;
|
||||
|
||||
/**
|
||||
* ResourceLoader FileModule for adding the content language Cite CSS
|
||||
|
@ -10,7 +11,7 @@ use MediaWiki\MediaWikiServices;
|
|||
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
||||
* @license MIT
|
||||
*/
|
||||
class CiteCSSFileModule extends \ResourceLoaderFileModule {
|
||||
class CiteCSSFileModule extends FileModule {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Cite\ResourceLoader;
|
||||
|
||||
use ResourceLoaderContext;
|
||||
use MediaWiki\ResourceLoader as RL;
|
||||
|
||||
/**
|
||||
* File module with extra data generated by the server.
|
||||
|
@ -12,19 +12,19 @@ use ResourceLoaderContext;
|
|||
* @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt
|
||||
* @license MIT
|
||||
*/
|
||||
class CiteVisualEditorModule extends \ResourceLoaderFileModule {
|
||||
class CiteVisualEditorModule extends RL\FileModule {
|
||||
|
||||
/** @inheritDoc */
|
||||
public function getScript( ResourceLoaderContext $context ) {
|
||||
public function getScript( RL\Context $context ) {
|
||||
return $this->makePrependedScript( $context ) . parent::getScript( $context );
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @param ResourceLoaderContext $context
|
||||
* @param RL\Context $context
|
||||
* @return string JavaScript code
|
||||
*/
|
||||
public function makePrependedScript( ResourceLoaderContext $context ) {
|
||||
public function makePrependedScript( RL\Context $context ) {
|
||||
$citationDefinition = json_decode(
|
||||
$context->msg( 'cite-tool-definition.json' )
|
||||
->inContentLanguage()
|
||||
|
@ -61,7 +61,7 @@ class CiteVisualEditorModule extends \ResourceLoaderFileModule {
|
|||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public function getDefinitionSummary( ResourceLoaderContext $context ) {
|
||||
public function getDefinitionSummary( RL\Context $context ) {
|
||||
$summary = parent::getDefinitionSummary( $context );
|
||||
$summary[] = [
|
||||
'script' => $this->makePrependedScript( $context ),
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Cite\Tests;
|
|||
|
||||
use Cite\ResourceLoader\CiteCSSFileModule;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use ResourceLoaderContext;
|
||||
use MediaWiki\ResourceLoader\Context;
|
||||
|
||||
/**
|
||||
* @covers \Cite\ResourceLoader\CiteCSSFileModule
|
||||
|
@ -24,7 +24,7 @@ class CiteCSSFileModuleTest extends \MediaWikiIntegrationTestCase {
|
|||
|
||||
public function testModule() {
|
||||
$module = new CiteCSSFileModule( [], __DIR__ . '/../../modules' );
|
||||
$styles = $module->getStyleFiles( $this->createMock( ResourceLoaderContext::class ) );
|
||||
$styles = $module->getStyleFiles( $this->createMock( Context::class ) );
|
||||
$this->assertSame( [ 'ext.cite.style.fa.css' ], $styles['all'] );
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
namespace Cite\Tests\Unit;
|
||||
|
||||
use Cite\ResourceLoader\CiteVisualEditorModule;
|
||||
use MediaWiki\ResourceLoader\Context;
|
||||
use Message;
|
||||
use ResourceLoaderContext;
|
||||
|
||||
/**
|
||||
* @covers \Cite\ResourceLoader\CiteVisualEditorModule
|
||||
|
@ -34,7 +34,7 @@ class CiteDataModuleTest extends \MediaWikiUnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
private function createResourceLoaderContext(): ResourceLoaderContext {
|
||||
private function createResourceLoaderContext(): Context {
|
||||
$msg = $this->createMock( Message::class );
|
||||
$msg->method( 'inContentLanguage' )
|
||||
->willReturnSelf();
|
||||
|
@ -43,7 +43,7 @@ class CiteDataModuleTest extends \MediaWikiUnitTestCase {
|
|||
$msg->method( 'text' )
|
||||
->willReturn( 't' );
|
||||
|
||||
$context = $this->createStub( ResourceLoaderContext::class );
|
||||
$context = $this->createStub( Context::class );
|
||||
$context->method( 'msg' )
|
||||
->withConsecutive(
|
||||
[ 'cite-tool-definition.json' ],
|
||||
|
|
Loading…
Reference in a new issue