NerdsAndCompany\Schematic\Services\Schematic::importFromYaml PHP Method

importFromYaml() public method

Import from Yaml file.
public importFromYaml ( string $file, string $override = null, boolean $force = false ) : Result
$file string
$override string
$force boolean if set to true items not included in import will be deleted
return NerdsAndCompany\Schematic\Models\Result
    public function importFromYaml($file, $override = null, $force = false)
    {
        Craft::app()->config->maxPowerCaptain();
        Craft::app()->setComponent('userSession', $this);
        $yaml = IOHelper::getFileContents($file);
        $yaml_override = IOHelper::getFileContents($override);
        $dataModel = Data::fromYaml($yaml, $yaml_override);
        return $this->importDataModel($dataModel, $force);
    }

Usage Example

Example #1
0
 /**
  * Test import from Yaml.
  *
  * @covers ::importFromYaml
  */
 public function testImportFromYamlWithForce()
 {
     $results = $this->schematicService->importFromYaml($this->getYamlTestFile(), null, true);
     $this->assertFalse($results->hasErrors());
 }