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'))
Definition: WebStart.php:88
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:144
const FORMAT_TEXT
Transform {{..}} constructs but don't transform to HTML.
Definition: Message.php:152
A simple factory providing a message formatter for a given language code.