comparison vendor/symfony/translation/Dumper/YamlFileDumper.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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\Dumper;
13
14 use Symfony\Component\Translation\MessageCatalogue;
15 use Symfony\Component\Translation\Util\ArrayConverter;
16 use Symfony\Component\Yaml\Yaml;
17 use Symfony\Component\Translation\Exception\LogicException;
18
19 /**
20 * YamlFileDumper generates yaml files from a message catalogue.
21 *
22 * @author Michel Salib <michelsalib@hotmail.com>
23 */
24 class YamlFileDumper extends FileDumper
25 {
26 /**
27 * {@inheritdoc}
28 */
29 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
30 {
31 if (!class_exists('Symfony\Component\Yaml\Yaml')) {
32 throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
33 }
34
35 $data = $messages->all($domain);
36
37 if (isset($options['as_tree']) && $options['as_tree']) {
38 $data = ArrayConverter::expandToTree($data);
39 }
40
41 if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) {
42 return Yaml::dump($data, $inline);
43 }
44
45 return Yaml::dump($data);
46 }
47
48 /**
49 * {@inheritdoc}
50 */
51 protected function getExtension()
52 {
53 return 'yml';
54 }
55 }