src/Command/CommandBase.php
public function writeYamlFile($filename, $data)
    {
        try {
            // @todo Allow the inline and indent variables to be set via command line option.
            $yaml = Yaml::dump($data->export(), 3, 2);
        } catch (\Exception $e) {
            $this->output->writeln("<error>There was an error dumping the YAML contents for $filename.</error>");
            $this->output->writeln($e->getMessage());

            return false;
        }

        try {
            // @todo Use Symfony file system instead so that exceptions can be caught.
            file_put_contents($filename, $yaml);
        } catch (\Exception $e) {
            $this->output->writeln("<error>There was an writing to $filename.</error>");
            $this->output->writeln($e->getMessage());

            return false;
        }

        return true;
    }
public function writeYamlFile($filename, $data)
    {
        try {
            // @todo Allow the inline and indent variables to be set via command line option.
            $yaml = Yaml::dump($data->export(), 3, 2);
        } catch (\Exception $e) {
            $this->output->writeln("<error>There was an error dumping the YAML contents for $filename.</error>");
            $this->output->writeln($e->getMessage());

            return false;
        }

        try {
            // @todo Use Symfony file system instead so that exceptions can be caught.
            file_put_contents($filename, $yaml);
        } catch (\Exception $e) {
            $this->output->writeln("<error>There was an writing to $filename.</error>");
            $this->output->writeln($e->getMessage());

            return false;
        }

        return true;
    }
public function writeYamlFile ( $ filename , $ data ) { try { // @todo Allow the inline and indent variables to be set via command line option. $ yaml = Yaml :: dump ( $ data -> export ( ) , 3 , 2 ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( "<error>There was an error dumping the YAML contents for $filename.</error>" ) ; $ this -> output -> writeln ( $ e -> getMessage ( ) ) ; return false ; } try { // @todo Use Symfony file system instead so that exceptions can be caught. file_put_contents ( $ filename , $ yaml ) ; } catch ( \ Exception $ e ) { $ this -> output -> writeln ( "<error>There was an writing to $filename.</error>" ) ; $ this -> output -> writeln ( $ e -> getMessage ( ) ) ; return false ; } return true ; }
Writes YAML data to a file.

@param string $filename
The filename.
@param Data $data
The YAML file contents.

@return bool
TRUE if file was written successfully. Otherwise, FALSE.
Writes YAML data to a file .