Class FormatterLocator
A ServiceLocator implementation for loading and retaining formatter objects.
Namespace: Cake\I18n
Property Summary
-
$converted protected
array<bool>
Tracks whether a registry entry has been converted from a FQCN to a formatter object.
-
$registry protected
array<string,Cake\I18n\FormatterInterface|class-stringCake\I18n\FormatterInterface>>
A registry to retain formatter objects.
Method Summary
-
__construct() public
Constructor.
-
get() public
Gets a formatter from the registry by name.
-
set() public
Sets a formatter into the registry by name.
Method Detail
__construct() ¶ public
__construct(array<string, class-stringCake\I18n\FormatterInterface>> $registry = [])
Constructor.
Parameters
-
array<string, class-stringCake\I18n\FormatterInterface>>
$registry optional An array of key-value pairs where the key is the formatter name the value is a FQCN for the formatter.
get() ¶ public
get(string $name): Cake\I18n\FormatterInterface
Gets a formatter from the registry by name.
Parameters
-
string
$name The formatter to retrieve.
Returns
Cake\I18n\FormatterInterface
Throws
Cake\I18n\Exception\I18nException
set() ¶ public
set(string $name, class-stringCake\I18n\FormatterInterface> $className): void
Sets a formatter into the registry by name.
Parameters
-
string
$name The formatter name.
-
class-stringCake\I18n\FormatterInterface>
$className A FQCN for a formatter.
Returns
void