mediawiki-extensions-Revisi.../RevisionSlider.hooks.php
Jakob Warkotsch 8c6676f939 Create module for Revision type.
This pulls out some of the code around revisions into a decoupled and
tested module.

Change-Id: Ib2a4f96f0e0b9a96ec85d300d97cd52dcaffe89e
2016-04-28 12:38:24 +02:00

35 lines
846 B
PHP
Executable file

<?php
/**
* RevisionSlider extension hooks
*
* @file
* @ingroup Extensions
* @license GPL-2.0+
*/
class RevisionSliderHooks {
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
if ( self::isRevisionPage( $skin->getContext()->getRequest() ) ) {
$out->addModules( 'ext.RevisionSlider.init' );
}
}
private static function isRevisionPage( WebRequest $request ) {
return $request->getVal( 'action' ) === 'history' || $request->getVal( 'type' ) === 'revision';
}
public static function onResourceLoaderTestModules( array &$testModules, ResourceLoader $rl ) {
$testModules['qunit']['ext.RevisionSlider.tests'] = [
'scripts' => [
'tests/RevisionSlider.Revision.test.js',
],
'dependencies' => [
'ext.RevisionSlider.Revision'
],
'localBasePath' => __DIR__,
];
return true;
}
}