NerdsAndCompany\Schematic\Models\Data::toYaml PHP Метод

toYaml() публичный статический Метод

Populate yaml from data model.
public static toYaml ( array $data ) : Data
$data array
Результат Data
    public static function toYaml(array $data)
    {
        $data = $data === null ? null : new static($data);
        return Yaml::dump($data->attributes, 12, 2);
    }

Usage Example

Пример #1
0
 /**
  * Export to Yaml file.
  *
  * @param string $file
  * @param bool   $autoCreate
  *
  * @return Result
  */
 public function exportToYaml($file, $autoCreate = true)
 {
     Craft::app()->config->maxPowerCaptain();
     $result = new Result();
     $dataModel = $this->exportDataModel();
     $yaml = Data::toYaml($dataModel);
     if (!IOHelper::writeToFile($file, $yaml, $autoCreate)) {
         // Do not auto create
         $result->addError('errors', "Failed to write contents to \"{$file}\"");
     }
     return $result;
 }
All Usage Examples Of NerdsAndCompany\Schematic\Models\Data::toYaml