Class PackageLocator
A ServiceLocator implementation for loading and retaining package objects.
Property Summary
-
$converted protected
array<string, array<string, bool>>
Tracks whether a registry entry has been converted from a callable to a Package object.
-
$registry protected
array<string, array<string,Cake\I18n\Package|callable>>
A registry of packages.
Method Summary
-
__construct() public
Constructor.
-
get() public
Gets a Package object.
-
has() public
Check if a Package object for given name and locale exists in registry.
-
set() public
Sets a Package loader.
Method Detail
__construct() ¶ public
__construct(array<string, array<string,Cake\I18n\Package|callable>> $registry = [])
Constructor.
Parameters
-
array<string, array<string,Cake\I18n\Package|callable>>
$registry optional A registry of packages.
See Also
get() ¶ public
get(string $name, string $locale): Cake\I18n\Package
Gets a Package object.
Parameters
-
string
$name The package name.
-
string
$locale The locale for the package.
Returns
Cake\I18n\Package
has() ¶ public
has(string $name, string $locale): bool
Check if a Package object for given name and locale exists in registry.
Parameters
-
string
$name The package name.
-
string
$locale The locale for the package.
Returns
bool
set() ¶ public
set(string $name, string $locale, Cake\I18n\Package|callable $spec): void
Sets a Package loader.
Parameters
-
string
$name The package name.
-
string
$locale The locale for the package.
-
Cake\I18n\Package|callable
$spec A callable that returns a package or Package instance.
Returns
void
Property Detail
$converted ¶ protected
Tracks whether a registry entry has been converted from a callable to a Package object.
Type
array<string, array<string, bool>>
$registry ¶ protected
A registry of packages.
Unlike many other registries, this one is two layers deep. The first key is a package name, the second key is a locale code, and the value is a callable that returns a Package object for that name and locale.
Type
array<string, array<string,Cake\I18n\Package|callable>>