composer package updates
[openemr.git] / vendor / symfony / translation / Dumper / YamlFileDumper.php
blobfdd113b103654adcc9e7a90fe7fb1af60a381259
1 <?php
3 /*
4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Dumper;
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;
19 /**
20 * YamlFileDumper generates yaml files from a message catalogue.
22 * @author Michel Salib <michelsalib@hotmail.com>
24 class YamlFileDumper extends FileDumper
26 /**
27 * {@inheritdoc}
29 public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array())
31 if (!class_exists('Symfony\Component\Yaml\Yaml')) {
32 throw new LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
35 $data = $messages->all($domain);
37 if (isset($options['as_tree']) && $options['as_tree']) {
38 $data = ArrayConverter::expandToTree($data);
41 if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) {
42 return Yaml::dump($data, $inline);
45 return Yaml::dump($data);
48 /**
49 * {@inheritdoc}
51 protected function getExtension()
53 return 'yml';