NerdsAndCompany\Schematic\Models\Data::fromYaml PHP Method

fromYaml() public static method

Populate data model from yaml.
public static fromYaml ( string $yaml, string $overrideYaml ) : Data
$yaml string
$overrideYaml string
return Data
    public static function fromYaml($yaml, $overrideYaml)
    {
        $data = Yaml::parse($yaml);
        if (!empty($overrideYaml)) {
            $overrideYaml = static::replaceEnvVariables($overrideYaml);
            $overrideData = Yaml::parse($overrideYaml);
            if ($overrideData != null) {
                $data = array_replace_recursive($data, $overrideData);
            }
        }
        return $data === null ? null : new static($data);
    }

Usage Example

Beispiel #1
0
 /**
  * Import from Yaml file.
  *
  * @param string $file
  * @param string $override
  * @param bool   $force    if set to true items not included in import will be deleted
  *
  * @return Result
  */
 public function importFromYaml($file, $override = null, $force = false)
 {
     Craft::app()->config->maxPowerCaptain();
     $yaml = IOHelper::getFileContents($file);
     $yaml_override = IOHelper::getFileContents($override);
     $dataModel = Data::fromYaml($yaml, $yaml_override);
     return $this->importDataModel($dataModel, $force);
 }
All Usage Examples Of NerdsAndCompany\Schematic\Models\Data::fromYaml