You are here

class YamlFileDumper in Plug 7

YamlFileDumper generates yaml files from a message catalogue.

@author Michel Salib <michelsalib@hotmail.com>

Hierarchy

Expanded class hierarchy of YamlFileDumper

1 file declares its use of YamlFileDumper
YamlFileDumperTest.php in lib/Symfony/translation/Tests/Dumper/YamlFileDumperTest.php

File

lib/Symfony/translation/Dumper/YamlFileDumper.php, line 23

Namespace

Symfony\Component\Translation\Dumper
View source
class YamlFileDumper extends FileDumper {

  /**
   * {@inheritdoc}
   */
  protected function formatCatalogue(MessageCatalogue $messages, $domain, array $options = array()) {
    if (!class_exists('Symfony\\Component\\Yaml\\Yaml')) {
      throw new \LogicException('Dumping translations in the YAML format requires the Symfony Yaml component.');
    }
    $data = $messages
      ->all($domain);
    if (isset($options['as_tree']) && $options['as_tree']) {
      $data = ArrayConverter::expandToTree($data);
    }
    if (isset($options['inline']) && ($inline = (int) $options['inline']) > 0) {
      return Yaml::dump($data, $inline);
    }
    return Yaml::dump($data);
  }

  /**
   * {@inheritdoc}
   */
  protected function format(MessageCatalogue $messages, $domain) {
    return $this
      ->formatCatalogue($messages, $domain);
  }

  /**
   * {@inheritdoc}
   */
  protected function getExtension() {
    return 'yml';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileDumper::$backup private property Make file backup before the dump.
FileDumper::$relativePathTemplate protected property A template for the relative paths to files. 1
FileDumper::dump public function Dumps the message catalogue. Overrides DumperInterface::dump 1
FileDumper::getRelativePath private function Gets the relative file path using the template.
FileDumper::setBackup public function Sets backup flag.
FileDumper::setRelativePathTemplate public function Sets the template for the relative paths to files.
YamlFileDumper::format protected function Transforms a domain of a message catalogue to its string representation. Overrides FileDumper::format
YamlFileDumper::formatCatalogue protected function Transforms a domain of a message catalogue to its string representation. Overrides FileDumper::formatCatalogue
YamlFileDumper::getExtension protected function Gets the file extension of the dumper. Overrides FileDumper::getExtension