MediaWiki  master
MessageFormatterFactory.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Message;
4 
5 use Message;
8 
12 class MessageFormatterFactory implements IMessageFormatterFactory {
13 
15  private $format;
16 
18  private $textFormatters = [];
19 
27  public function __construct( string $format = Message::FORMAT_TEXT ) {
28  $this->format = $format;
29  }
30 
34  public function getTextFormatter( $langCode ): ITextFormatter {
35  if ( !isset( $this->textFormatters[$langCode] ) ) {
36  $this->textFormatters[$langCode] = new TextFormatter(
37  $langCode, new Converter(), $this->format );
38  }
39  return $this->textFormatters[$langCode];
40  }
41 }
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition: WebStart.php:82
Converter between Message and MessageValue.
Definition: Converter.php:18
The MediaWiki-specific implementation of IMessageFormatterFactory.
__construct(string $format=Message::FORMAT_TEXT)
Required parameters may be added to this function without deprecation.
getTextFormatter( $langCode)
Get a text message formatter for a given language.The language code ITextFormatter
The MediaWiki-specific implementation of ITextFormatter.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition: Message.php:141
const FORMAT_TEXT
Transform {{..}} constructs but don't transform to HTML.
Definition: Message.php:149
A simple factory providing a message formatter for a given language code.