Update git submodules
[mediawiki.git] / includes / Message / MessageFormatterFactory.php
bloba1a8c47ce56f26047fefb1ded8d6ef735b1f9b55
1 <?php
3 namespace MediaWiki\Message;
5 use Message;
6 use Wikimedia\Message\IMessageFormatterFactory;
7 use Wikimedia\Message\ITextFormatter;
9 /**
10 * The MediaWiki-specific implementation of IMessageFormatterFactory
12 class MessageFormatterFactory implements IMessageFormatterFactory {
14 /** @var string */
15 private $format;
17 /** @var array */
18 private $textFormatters = [];
20 /**
21 * Required parameters may be added to this function without deprecation.
22 * External callers should use MediaWikiServices::getMessageFormatterFactory().
24 * @param string $format which if the Message::FORMAT_* to use in the formatters.
25 * @internal
27 public function __construct( string $format = Message::FORMAT_TEXT ) {
28 $this->format = $format;
31 /**
32 * @inheritDoc
34 public function getTextFormatter( $langCode ): ITextFormatter {
35 if ( !isset( $this->textFormatters[$langCode] ) ) {
36 $this->textFormatters[$langCode] = new TextFormatter(
37 $langCode, new Converter(), $this->format );
39 return $this->textFormatters[$langCode];