NerdsAndCompany\Schematic\Services\GlobalSets::import PHP Method

import() public method

Attempt to import globals.
public import ( array $globalSetDefinitions, boolean $force = false ) : Result
$globalSetDefinitions array
$force boolean If set to true globals not included in the import will be deleted
return Result
    public function import(array $globalSetDefinitions, $force = false)
    {
        Craft::log(Craft::t('Importing Global Sets'));
        $globalSets = Craft::app()->globals->getAllSets('handle');
        foreach ($globalSetDefinitions as $globalSetHandle => $globalSetDefinition) {
            $global = array_key_exists($globalSetHandle, $globalSets) ? $globalSets[$globalSetHandle] : new GlobalSetModel();
            unset($globalSets[$globalSetHandle]);
            $this->populateGlobalSet($global, $globalSetDefinition, $globalSetHandle);
            if (!Craft::app()->globals->saveSet($global)) {
                // Save globalset via craft
                $this->addErrors($global->getAllErrors());
                continue;
            }
        }
        if ($force) {
            foreach ($globalSets as $globalSet) {
                Craft::app()->globals->deleteSetById($globalSet->id);
            }
        }
        return $this->getResultModel();
    }