mediawiki-extensions-Templa.../includes/CodeEditorHooks.php
Umherirrender b5ab3bac24 Use HookHandlers for CodeEditor hook
Bug: T338435
Change-Id: I7c2cb3ca5e38ce974187af316bf30e71b8e4ad49
2023-11-06 12:00:18 -05:00

36 lines
925 B
PHP

<?php
namespace MediaWiki\Extension\TemplateStyles;
/**
* @file
* @license GPL-2.0-or-later
*/
use MediaWiki\Extension\CodeEditor\Hooks\CodeEditorGetPageLanguageHook;
use MediaWiki\Title\Title;
/**
* TemplateStyles extension hooks
* All hooks from the CodeEditor extension which is optional to use with this extension.
*/
class CodeEditorHooks implements
CodeEditorGetPageLanguageHook
{
/**
* Edit our CSS content model like core's CSS
* @param Title $title Title being edited
* @param string|null &$lang CodeEditor language to use
* @param string $model Content model
* @param string $format Content format
* @return bool
*/
public function onCodeEditorGetPageLanguage( Title $title, ?string &$lang, string $model, string $format ): bool {
if ( $model === 'sanitized-css' && Hooks::getConfig()->get( 'TemplateStylesUseCodeEditor' ) ) {
$lang = 'css';
return false;
}
return true;
}
}