W3cubDocs

/CakePHP 4.4

Class PackageLocator

A ServiceLocator implementation for loading and retaining package objects.

Namespace: Cake\I18n

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

PackageLocator::$registry

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>>

© 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.PackageLocator.html