3 * Content handler for the pages with code, such as CSS, JavaScript, JSON.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 namespace MediaWiki\Content
;
27 use MediaWiki\Language\Language
;
28 use MediaWiki\MediaWikiServices
;
29 use MediaWiki\Title\Title
;
32 * Content handler for code content such as CSS, JavaScript, JSON, etc.
38 abstract class CodeContentHandler
extends TextContentHandler
{
41 * Returns the English language, because code is English, and should be handled as such.
46 * @param Content|null $content
50 * @see ContentHandler::getPageLanguage()
52 public function getPageLanguage( Title
$title, ?Content
$content = null ) {
53 return MediaWikiServices
::getInstance()->getLanguageFactory()->getLanguage( 'en' );
57 * Returns the English language, because code is English, and should be handled as such.
62 * @param Content|null $content
66 * @see ContentHandler::getPageViewLanguage()
68 public function getPageViewLanguage( Title
$title, ?Content
$content = null ) {
69 return MediaWikiServices
::getInstance()->getLanguageFactory()->getLanguage( 'en' );
73 protected function getContentClass() {
74 throw new LogicException( 'Subclass must override' );
78 /** @deprecated class alias since 1.43 */
79 class_alias( CodeContentHandler
::class, 'CodeContentHandler' );