PhpFileLoader.php 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Loader;
  11. use Symfony\Component\Config\Resource\FileResource;
  12. /**
  13. * PhpFileLoader loads translations from PHP files returning an array of translations.
  14. *
  15. * @author Fabien Potencier <fabien@symfony.com>
  16. *
  17. * @api
  18. */
  19. class PhpFileLoader extends ArrayLoader implements LoaderInterface
  20. {
  21. /**
  22. * {@inheritdoc}
  23. *
  24. * @api
  25. */
  26. public function load($resource, $locale, $domain = 'messages')
  27. {
  28. $messages = require($resource);
  29. $catalogue = parent::load($messages, $locale, $domain);
  30. $catalogue->addResource(new FileResource($resource));
  31. return $catalogue;
  32. }
  33. }