W3cubDocs

/CakePHP 4.4

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

Property Detail

$converted protected

Tracks whether a registry entry has been converted from a FQCN to a formatter object.

Type

array<bool>

$registry protected

A registry to retain formatter objects.

Type

array<string,Cake\I18n\FormatterInterface|class-stringCake\I18n\FormatterInterface>>

© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.I18n.FormatterLocator.html