Class PackageLocator
A ServiceLocator implementation for loading and retaining package objects.
Property Summary
-
$converted protected
array
Tracks whether or not a registry entry has been converted from a callable to a Package object.
-
$registry protected
array
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 $registry = [])
Constructor.
Parameters
-
array
$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, callableCake\I18n\Package $spec): void
Sets a Package loader.
Parameters
-
string
$name The package name.
-
string
$locale The locale for the package.
-
callableCake\I18n\Package
$spec A callable that returns a package or Package instance.
Returns
void
Property Detail
$converted ¶ protected
Tracks whether or not a registry entry has been converted from a callable to a Package object.
Type
array
$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