class TranslatorAdapterRepository implements TranslatorAdapterRepositoryInterface (View source)

Basic implementation of the TranslatorAdapterRepositoryInterface.

Stores the translator adapters in a local array.

Constants

KEY_SEPARATOR

Properties

protected Application $app
protected array $adapters

Methods

__construct(TranslatorAdapterFactoryInterface $translatorAdapterFactory)

No description

registerTranslatorAdapter(string $handle, string $locale, TranslatorAdapterInterface $translatorAdater)

Registers the translator for the given handle and locale to be the object provided as the third parameter. The passed adapter needs to implement the TranslatorAdapterInterface.

hasTranslatorAdapter(string $handle, string $locale)

Checks whether a translator has been defined for the given handle and locale.

mixed
getTranslatorAdapter(string $handle, string $locale)

Gets the translator for the given handle and locale. This will also initialize the translator object for the given handle if it has not been fetched previously through this method.

removeTranslatorAdapter(string $handle, string $locale)

Removes the translator for the given handle and locale.

removeTranslatorAdaptersWithHandle($handle)

Removes all the translators for the given handle, no matter what their locale is.

string
getKey($handle, $locale)

Generates a store key for the given handle and locale. The translator for the combination of these two is stored in the local array with the key returned by this method.

Details

__construct(TranslatorAdapterFactoryInterface $translatorAdapterFactory)

No description

Parameters

TranslatorAdapterFactoryInterface $translatorAdapterFactory

registerTranslatorAdapter(string $handle, string $locale, TranslatorAdapterInterface $translatorAdater)

Registers the translator for the given handle and locale to be the object provided as the third parameter. The passed adapter needs to implement the TranslatorAdapterInterface.

Parameters

string $handle
string $locale
TranslatorAdapterInterface $translatorAdater

hasTranslatorAdapter(string $handle, string $locale)

Checks whether a translator has been defined for the given handle and locale.

Parameters

string $handle
string $locale

mixed getTranslatorAdapter(string $handle, string $locale)

Gets the translator for the given handle and locale. This will also initialize the translator object for the given handle if it has not been fetched previously through this method.

Parameters

string $handle
string $locale

Return Value

mixed

The translator object

removeTranslatorAdapter(string $handle, string $locale)

Removes the translator for the given handle and locale.

Parameters

string $handle
string $locale

removeTranslatorAdaptersWithHandle($handle)

Removes all the translators for the given handle, no matter what their locale is.

Parameters

$handle

protected string getKey($handle, $locale)

Generates a store key for the given handle and locale. The translator for the combination of these two is stored in the local array with the key returned by this method.

Parameters

$handle
$locale

Return Value

string