]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
1 | <?php |
2 | ||
3 | /* | |
4 | * This file is part of the Symfony package. | |
5 | * | |
6 | * (c) Fabien Potencier <fabien@symfony.com> | |
7 | * | |
8 | * For the full copyright and license information, please view the LICENSE | |
9 | * file that was distributed with this source code. | |
10 | */ | |
11 | ||
12 | namespace Symfony\Component\Intl\ResourceBundle\Reader; | |
13 | ||
14 | use Symfony\Component\Intl\Exception\RuntimeException; | |
15 | use Symfony\Component\Intl\ResourceBundle\Util\ArrayAccessibleResourceBundle; | |
16 | ||
17 | /** | |
18 | * Reads binary .res resource bundles. | |
19 | * | |
20 | * @author Bernhard Schussek <bschussek@gmail.com> | |
21 | */ | |
22 | class BinaryBundleReader extends AbstractBundleReader implements BundleReaderInterface | |
23 | { | |
24 | /** | |
25 | * {@inheritdoc} | |
26 | */ | |
27 | public function read($path, $locale) | |
28 | { | |
29 | // Point for future extension: Modify this class so that it works also | |
30 | // if the \ResourceBundle class is not available. | |
31 | $bundle = new \ResourceBundle($locale, $path); | |
32 | ||
33 | if (null === $bundle) { | |
34 | throw new RuntimeException(sprintf( | |
35 | 'Could not load the resource bundle "%s/%s.res".', | |
36 | $path, | |
37 | $locale | |
38 | )); | |
39 | } | |
40 | ||
41 | return new ArrayAccessibleResourceBundle($bundle); | |
42 | } | |
43 | ||
44 | /** | |
45 | * {@inheritdoc} | |
46 | */ | |
47 | protected function getFileExtension() | |
48 | { | |
49 | return 'res'; | |
50 | } | |
51 | } |