AbstractBundleReader.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\Reader;
  11. /**
  12. * Base class for {@link BundleReaderInterface} implementations.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. abstract class AbstractBundleReader implements BundleReaderInterface
  17. {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function getLocales($path)
  22. {
  23. $extension = '.' . $this->getFileExtension();
  24. $locales = glob($path . '/*' . $extension);
  25. // Remove file extension and sort
  26. array_walk($locales, function (&$locale) use ($extension) { $locale = basename($locale, $extension); });
  27. sort($locales);
  28. return $locales;
  29. }
  30. /**
  31. * Returns the extension of locale files in this bundle.
  32. *
  33. * @return string The file extension (without leading dot).
  34. */
  35. abstract protected function getFileExtension();
  36. }