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