wiki.techinc.nl/includes/language/FormatterFactory.php
daniel 04197cb13f Introduce StatusFormatter
This takes us one step closer to deprecating Status,
so we can isolate StatusValue from presentation logic.

FormatterFactory is introduced as a mechanism for
getting instance of formatters that need access to the user interface
language and other request dependent information.

Usage is demonstrated in thumb.php, SpecialCreateAccount, and
SearchHandler. The examples indicates that there is no work do
be done around ErrorPageError and LocalizedHttpException.

Change-Id: I7fe5fee24cadf934e578c36856cc5d45fb9d0981
2023-10-27 14:56:51 +02:00

29 lines
582 B
PHP

<?php
namespace MediaWiki\Language;
use MediaWiki\Status\StatusFormatter;
use MessageCache;
use MessageLocalizer;
/**
* Factory for formatters of common complex objects
*
* @since 1.42
*/
class FormatterFactory {
private MessageCache $messageCache;
/**
* @param MessageCache $messageCache
*/
public function __construct( MessageCache $messageCache ) {
$this->messageCache = $messageCache;
}
public function getStatusFormatter( MessageLocalizer $messageLocalizer ): StatusFormatter {
return new StatusFormatter( $messageLocalizer, $this->messageCache );
}
}