You are here

public function PhpFileLoader::load in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/routing/Loader/PhpFileLoader.php \Symfony\Component\Routing\Loader\PhpFileLoader::load()
  2. 8 vendor/symfony/translation/Loader/PhpFileLoader.php \Symfony\Component\Translation\Loader\PhpFileLoader::load()
  3. 8 vendor/symfony/dependency-injection/Loader/PhpFileLoader.php \Symfony\Component\DependencyInjection\Loader\PhpFileLoader::load()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/translation/Loader/PhpFileLoader.php \Symfony\Component\Translation\Loader\PhpFileLoader::load()

Loads a locale.

Parameters

mixed $resource A resource:

string $locale A locale:

string $domain The domain:

Return value

MessageCatalogue A MessageCatalogue instance

Throws

NotFoundResourceException when the resource cannot be found

InvalidResourceException when the resource cannot be loaded

Overrides ArrayLoader::load

File

vendor/symfony/translation/Loader/PhpFileLoader.php, line 28

Class

PhpFileLoader
PhpFileLoader loads translations from PHP files returning an array of translations.

Namespace

Symfony\Component\Translation\Loader

Code

public function load($resource, $locale, $domain = 'messages') {
  if (!stream_is_local($resource)) {
    throw new InvalidResourceException(sprintf('This is not a local file "%s".', $resource));
  }
  if (!file_exists($resource)) {
    throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
  }
  $messages = (require $resource);
  $catalogue = parent::load($messages, $locale, $domain);
  if (class_exists('Symfony\\Component\\Config\\Resource\\FileResource')) {
    $catalogue
      ->addResource(new FileResource($resource));
  }
  return $catalogue;
}