Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
DocumentationAid
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 getData
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2declare( strict_types = 1 );
3
4namespace MediaWiki\Extension\Translate\TranslatorInterface\Aid;
5
6use MediaWiki\Extension\Translate\TranslatorInterface\TranslationHelperException;
7use MediaWiki\Extension\Translate\Utilities\Utilities;
8use MediaWiki\MediaWikiServices;
9
10/**
11 * Translation aid that provides the message documentation.
12 * @author Niklas Laxström
13 * @license GPL-2.0-or-later
14 * @since 2013-01-01
15 * @ingroup TranslationAids
16 */
17class DocumentationAid extends TranslationAid {
18    public function getData(): array {
19        global $wgTranslateDocumentationLanguageCode;
20        if ( !$wgTranslateDocumentationLanguageCode ) {
21            throw new TranslationHelperException( 'Message documentation is disabled' );
22        }
23
24        $page = $this->handle->getKey();
25        $ns = $this->handle->getTitle()->getNamespace();
26
27        $info = Utilities::getMessageContent( $page, $wgTranslateDocumentationLanguageCode, $ns ) ?? '';
28
29        return [
30            'language' => MediaWikiServices::getInstance()->getContentLanguage()->getCode(),
31            'value' => $info,
32            'html' => $this->context->getOutput()->parseAsInterface( $info )
33        ];
34    }
35}