AbstractBundle.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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\Intl\ResourceBundle;
  11. use Symfony\Component\Intl\Intl;
  12. use Symfony\Component\Intl\ResourceBundle\Reader\StructuredBundleReaderInterface;
  13. /**
  14. * Base class for {@link ResourceBundleInterface} implementations.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. abstract class AbstractBundle implements ResourceBundleInterface
  19. {
  20. /**
  21. * @var string
  22. */
  23. private $path;
  24. /**
  25. * @var StructuredBundleReaderInterface
  26. */
  27. private $reader;
  28. /**
  29. * Creates a bundle at the given path using the given reader for reading
  30. * bundle entries.
  31. *
  32. * @param string $path The path to the bundle.
  33. * @param StructuredBundleReaderInterface $reader The reader for reading
  34. * the bundle.
  35. */
  36. public function __construct($path, StructuredBundleReaderInterface $reader)
  37. {
  38. $this->path = $path;
  39. $this->reader = $reader;
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function getLocales()
  45. {
  46. return $this->reader->getLocales($this->path);
  47. }
  48. /**
  49. * Proxy method for {@link StructuredBundleReaderInterface#read}.
  50. */
  51. protected function read($locale)
  52. {
  53. return $this->reader->read($this->path, $locale);
  54. }
  55. /**
  56. * Proxy method for {@link StructuredBundleReaderInterface#readEntry}.
  57. */
  58. protected function readEntry($locale, array $indices, $mergeFallback = false)
  59. {
  60. return $this->reader->readEntry($this->path, $locale, $indices, $mergeFallback);
  61. }
  62. }