Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CodeEditorHooks
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 onCodeEditorGetPageLanguage
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace MediaWiki\Extension\TemplateStyles;
4
5/**
6 * @file
7 * @license GPL-2.0-or-later
8 */
9
10use MediaWiki\Extension\CodeEditor\Hooks\CodeEditorGetPageLanguageHook;
11use MediaWiki\Title\Title;
12
13/**
14 * TemplateStyles extension hooks
15 * All hooks from the CodeEditor extension which is optional to use with this extension.
16 */
17class CodeEditorHooks implements
18    CodeEditorGetPageLanguageHook
19{
20    /**
21     * Edit our CSS content model like core's CSS
22     * @param Title $title Title being edited
23     * @param string|null &$lang CodeEditor language to use
24     * @param string $model Content model
25     * @param string $format Content format
26     * @return bool
27     */
28    public function onCodeEditorGetPageLanguage( Title $title, ?string &$lang, string $model, string $format ): bool {
29        if ( $model === 'sanitized-css' && Hooks::getConfig()->get( 'TemplateStylesUseCodeEditor' ) ) {
30            $lang = 'css';
31            return false;
32        }
33        return true;
34    }
35}