1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,50 +0,0 @@ |
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\Translation\Loader; |
|
13 |
- |
|
14 |
-use Symfony\Component\Translation\Exception\InvalidResourceException; |
|
15 |
-use Symfony\Component\Translation\Exception\LogicException; |
|
16 |
-use Symfony\Component\Yaml\Exception\ParseException; |
|
17 |
-use Symfony\Component\Yaml\Parser as YamlParser; |
|
18 |
-use Symfony\Component\Yaml\Yaml; |
|
19 |
- |
|
20 |
-/** |
|
21 |
- * YamlFileLoader loads translations from Yaml files. |
|
22 |
- * |
|
23 |
- * @author Fabien Potencier <fabien@symfony.com> |
|
24 |
- */ |
|
25 |
-class YamlFileLoader extends FileLoader |
|
26 |
-{ |
|
27 |
- private $yamlParser; |
|
28 |
- |
|
29 |
- /** |
|
30 |
- * {@inheritdoc} |
|
31 |
- */ |
|
32 |
- protected function loadResource($resource) |
|
33 |
- { |
|
34 |
- if (null === $this->yamlParser) { |
|
35 |
- if (!class_exists('Symfony\Component\Yaml\Parser')) { |
|
36 |
- throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); |
|
37 |
- } |
|
38 |
- |
|
39 |
- $this->yamlParser = new YamlParser(); |
|
40 |
- } |
|
41 |
- |
|
42 |
- try { |
|
43 |
- $messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT); |
|
44 |
- } catch (ParseException $e) { |
|
45 |
- throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e); |
|
46 |
- } |
|
47 |
- |
|
48 |
- return $messages; |
|
49 |
- } |
|
50 |
-} |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,50 @@ |
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\Translation\Loader; |
|
13 |
+ |
|
14 |
+use Symfony\Component\Translation\Exception\InvalidResourceException; |
|
15 |
+use Symfony\Component\Translation\Exception\LogicException; |
|
16 |
+use Symfony\Component\Yaml\Exception\ParseException; |
|
17 |
+use Symfony\Component\Yaml\Parser as YamlParser; |
|
18 |
+use Symfony\Component\Yaml\Yaml; |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * YamlFileLoader loads translations from Yaml files. |
|
22 |
+ * |
|
23 |
+ * @author Fabien Potencier <fabien@symfony.com> |
|
24 |
+ */ |
|
25 |
+class YamlFileLoader extends FileLoader |
|
26 |
+{ |
|
27 |
+ private $yamlParser; |
|
28 |
+ |
|
29 |
+ /** |
|
30 |
+ * {@inheritdoc} |
|
31 |
+ */ |
|
32 |
+ protected function loadResource($resource) |
|
33 |
+ { |
|
34 |
+ if (null === $this->yamlParser) { |
|
35 |
+ if (!class_exists('Symfony\Component\Yaml\Parser')) { |
|
36 |
+ throw new LogicException('Loading translations from the YAML format requires the Symfony Yaml component.'); |
|
37 |
+ } |
|
38 |
+ |
|
39 |
+ $this->yamlParser = new YamlParser(); |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ try { |
|
43 |
+ $messages = $this->yamlParser->parseFile($resource, Yaml::PARSE_CONSTANT); |
|
44 |
+ } catch (ParseException $e) { |
|
45 |
+ throw new InvalidResourceException(sprintf('Error parsing YAML, invalid file "%s"', $resource), 0, $e); |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ return $messages; |
|
49 |
+ } |
|
50 |
+} |