Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5986920
TextFormatter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
TextFormatter.php
View Options
<?php
namespace
MediaWiki\Message
;
use
Wikimedia\Message\ITextFormatter
;
use
Wikimedia\Message\MessageSpecifier
;
/**
* The MediaWiki-specific implementation of ITextFormatter
*
* To obtain an instance, use \MediaWiki\MediaWikiServices::getMessageFormatterFactory()
* and call MessageFormatterFactory::getTextFormatter.
*
* @ingroup Language
*/
class
TextFormatter
implements
ITextFormatter
{
private
string
$langCode
;
private
string
$format
;
/**
* @internal For use by ServiceWiring only
* @param string $langCode
* @param string $format
*/
public
function
__construct
(
string
$langCode
,
string
$format
=
Message
::
FORMAT_TEXT
)
{
$this
->
langCode
=
$langCode
;
$this
->
format
=
$format
;
}
public
function
getLangCode
():
string
{
return
$this
->
langCode
;
}
/**
* Allow the Message class to be mocked in tests by constructing objects in
* a protected method.
*
* @internal
* @param MessageSpecifier $spec
* @return Message
*/
protected
function
createMessage
(
MessageSpecifier
$spec
):
Message
{
return
Message
::
newFromSpecifier
(
$spec
);
}
public
function
format
(
MessageSpecifier
$mv
):
string
{
$message
=
$this
->
createMessage
(
$mv
);
$message
->
inLanguage
(
$this
->
langCode
);
return
$message
->
toString
(
$this
->
format
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 4, 00:15 (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
24/18/e8183093a6d2fa8e9b0e3c7346d6
Default Alt Text
TextFormatter.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment