/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/I18n
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/cakephp/src/I18n/PackageLocator.php (3488B)
>
*/
protected $registry = [];
/**
* Tracks whether a registry entry has been converted from a
* callable to a Package object.
*
* @var array
>
*/
protected $converted = [];
/**
* Constructor.
*
* @param array> $registry A registry of packages.
* @see PackageLocator::$registry
*/
public function __construct(array $registry = [])
{
foreach ($registry as $name => $locales) {
foreach ($locales as $locale => $spec) {
$this->set($name, $locale, $spec);
}
}
}
/**
* Sets a Package loader.
*
* @param string $name The package name.
* @param string $locale The locale for the package.
* @param \Cake\I18n\Package|callable $spec A callable that returns a package or Package instance.
* @return void
*/
public function set(string $name, string $locale, $spec): void
{
$this->registry[$name][$locale] = $spec;
$this->converted[$name][$locale] = $spec instanceof Package;
}
/**
* Gets a Package object.
*
* @param string $name The package name.
* @param string $locale The locale for the package.
* @return \Cake\I18n\Package
*/
public function get(string $name, string $locale): Package
{
if (!isset($this->registry[$name][$locale])) {
throw new I18nException("Package '$name' with locale '$locale' is not registered.");
}
if (!$this->converted[$name][$locale]) {
/** @var callable $func */
$func = $this->registry[$name][$locale];
$this->registry[$name][$locale] = $func();
$this->converted[$name][$locale] = true;
}
/** @var \Cake\I18n\Package */
return $this->registry[$name][$locale];
}
/**
* Check if a Package object for given name and locale exists in registry.
*
* @param string $name The package name.
* @param string $locale The locale for the package.
* @return bool
*/
public function has(string $name, string $locale): bool
{
return isset($this->registry[$name][$locale]);
}
}