mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-12-01 01:56:20 +00:00
Merge "Rename CiteParserTagHooks::initialize to register"
This commit is contained in:
commit
0dafe64305
|
@ -18,7 +18,7 @@ class CiteParserHooks {
|
||||||
*/
|
*/
|
||||||
public static function onParserFirstCallInit( Parser $parser ) {
|
public static function onParserFirstCallInit( Parser $parser ) {
|
||||||
$parser->extCite = new Cite();
|
$parser->extCite = new Cite();
|
||||||
CiteParserTagHooks::initialize( $parser );
|
CiteParserTagHooks::register( $parser );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +44,7 @@ class CiteParserHooks {
|
||||||
$cite = $parser->extCite;
|
$cite = $parser->extCite;
|
||||||
$cite->clearState( 'force' );
|
$cite->clearState( 'force' );
|
||||||
|
|
||||||
CiteParserTagHooks::initialize( $parser );
|
CiteParserTagHooks::register( $parser );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,9 +16,9 @@ class CiteParserTagHooks {
|
||||||
*
|
*
|
||||||
* @param Parser $parser
|
* @param Parser $parser
|
||||||
*/
|
*/
|
||||||
public static function initialize( Parser $parser ) {
|
public static function register( Parser $parser ) {
|
||||||
$parser->setHook( 'ref', __CLASS__ . '::ref' );
|
$parser->setHook( 'ref', [ __CLASS__, 'ref' ] );
|
||||||
$parser->setHook( 'references', __CLASS__ . '::references' );
|
$parser->setHook( 'references', [ __CLASS__, 'references' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,6 @@ class CiteParserTagHooks {
|
||||||
public static function ref( $content, array $attributes, Parser $parser, PPFrame $frame ) {
|
public static function ref( $content, array $attributes, Parser $parser, PPFrame $frame ) {
|
||||||
/** @var Cite $cite */
|
/** @var Cite $cite */
|
||||||
$cite = $parser->extCite;
|
$cite = $parser->extCite;
|
||||||
// @phan-suppress-next-line SecurityCheck-XSS False positive
|
|
||||||
$result = $cite->ref( $content, $attributes, $parser );
|
$result = $cite->ref( $content, $attributes, $parser );
|
||||||
|
|
||||||
if ( $result === false ) {
|
if ( $result === false ) {
|
||||||
|
@ -46,6 +45,7 @@ class CiteParserTagHooks {
|
||||||
$parserOutput->addModuleStyles( 'ext.cite.styles' );
|
$parserOutput->addModuleStyles( 'ext.cite.styles' );
|
||||||
|
|
||||||
$frame->setVolatile();
|
$frame->setVolatile();
|
||||||
|
// @phan-suppress-next-line SecurityCheck-XSS False positive
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,6 @@ class CiteParserTagHooks {
|
||||||
public static function references( $content, array $attributes, Parser $parser, PPFrame $frame ) {
|
public static function references( $content, array $attributes, Parser $parser, PPFrame $frame ) {
|
||||||
/** @var Cite $cite */
|
/** @var Cite $cite */
|
||||||
$cite = $parser->extCite;
|
$cite = $parser->extCite;
|
||||||
// @phan-suppress-next-line SecurityCheck-XSS False positive
|
|
||||||
$result = $cite->references( $content, $attributes, $parser );
|
$result = $cite->references( $content, $attributes, $parser );
|
||||||
|
|
||||||
if ( $result === false ) {
|
if ( $result === false ) {
|
||||||
|
@ -73,6 +72,7 @@ class CiteParserTagHooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
$frame->setVolatile();
|
$frame->setVolatile();
|
||||||
|
// @phan-suppress-next-line SecurityCheck-XSS False positive
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ use PPFrame;
|
||||||
class CiteParserTagHooksTest extends \MediaWikiUnitTestCase {
|
class CiteParserTagHooksTest extends \MediaWikiUnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::initialize
|
* @covers ::register
|
||||||
*/
|
*/
|
||||||
public function testInitialize() {
|
public function testRegister() {
|
||||||
$parser = $this->createMock( Parser::class );
|
$parser = $this->createMock( Parser::class );
|
||||||
$parser->expects( $this->exactly( 2 ) )
|
$parser->expects( $this->exactly( 2 ) )
|
||||||
->method( 'setHook' )
|
->method( 'setHook' )
|
||||||
|
@ -27,7 +27,7 @@ class CiteParserTagHooksTest extends \MediaWikiUnitTestCase {
|
||||||
[ 'references', $this->isType( 'callable' ) ]
|
[ 'references', $this->isType( 'callable' ) ]
|
||||||
);
|
);
|
||||||
|
|
||||||
CiteParserTagHooks::initialize( $parser );
|
CiteParserTagHooks::register( $parser );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue