Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / content / CodeContentHandler.php
blobd3c23f5a1aed969ca2f9aea4401d2af86d0d089a
1 <?php
2 /**
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
20 * @file
21 * @ingroup Content
24 namespace MediaWiki\Content;
26 use LogicException;
27 use MediaWiki\Language\Language;
28 use MediaWiki\MediaWikiServices;
29 use MediaWiki\Title\Title;
31 /**
32 * Content handler for code content such as CSS, JavaScript, JSON, etc.
34 * @stable to extend
35 * @since 1.24
36 * @ingroup Content
38 abstract class CodeContentHandler extends TextContentHandler {
40 /**
41 * Returns the English language, because code is English, and should be handled as such.
43 * @stable to override
45 * @param Title $title
46 * @param Content|null $content
48 * @return Language
50 * @see ContentHandler::getPageLanguage()
52 public function getPageLanguage( Title $title, ?Content $content = null ) {
53 return MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
56 /**
57 * Returns the English language, because code is English, and should be handled as such.
59 * @stable to override
61 * @param Title $title
62 * @param Content|null $content
64 * @return Language
66 * @see ContentHandler::getPageViewLanguage()
68 public function getPageViewLanguage( Title $title, ?Content $content = null ) {
69 return MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
72 /** @inheritDoc */
73 protected function getContentClass() {
74 throw new LogicException( 'Subclass must override' );
78 /** @deprecated class alias since 1.43 */
79 class_alias( CodeContentHandler::class, 'CodeContentHandler' );