public function createSettingMigration($data)
    {

        $manifest = [];

        $migration = array(
            'settings' => array(
                'dependencies' => array(),
                'elements' => array(),
            ),
        );

        $empty = true;

        //build a list of dependencies first to avoid potential cases where items are requested by fields before being created
        //export them without additional fields to prevent conflicts with missing fields, field tabs can be added on the second pass
        //after all the fields have been created
        $plugin = MigrationManager::getInstance();

        foreach ($this->_settingsDependencyTypes as $key => $value) {
            $service = $plugin->get($value);
            if (array_key_exists($service->getSource(), $data)) {
                $migration['settings']['dependencies'][$service->getDestination()] = $service->export($data[$service->getSource()], false);
                $empty = false;

                if ($service->hasErrors()) {
                    $errors = $service->getErrors();
                    foreach ($errors as $error) {
                        Craft::error($error, __METHOD__);
                    }

                    return false;
                }
            }
        }

        foreach ($this->_settingsMigrationTypes as $key => $value) {
            $service = $plugin->get($value);
            if (array_key_exists($service->getSource(), $data)) {
                $migration['settings']['elements'][$service->getDestination()] = $service->export($data[$service->getSource()], true);
                $empty = false;

                if ($service->hasErrors()) {
                    $errors = $service->getErrors();
                    foreach ($errors as $error) {
                        Craft::error($error, __METHOD__);
                    }

                    return false;
                }
                $manifest = array_merge($manifest, [$key => $service->getManifest()]);
            }
        }

        if ($empty) {
            $migration = null;
        }

        if (array_key_exists('migrationName', $data)){
            $migrationName = trim($data['migrationName']);
            $migrationName = str_replace(' ', '_', $migrationName);
        } else {
            $migrationName = '';
        }

        $this->createMigration($migration, $manifest, $migrationName);

        return true;
    }
public function createSettingMigration($data)
    {

        $manifest = [];

        $migration = array(
            'settings' => array(
                'dependencies' => array(),
                'elements' => array(),
            ),
        );

        $empty = true;

        //build a list of dependencies first to avoid potential cases where items are requested by fields before being created
        //export them without additional fields to prevent conflicts with missing fields, field tabs can be added on the second pass
        //after all the fields have been created
        $plugin = MigrationManager::getInstance();

        foreach ($this->_settingsDependencyTypes as $key => $value) {
            $service = $plugin->get($value);
            if (array_key_exists($service->getSource(), $data)) {
                $migration['settings']['dependencies'][$service->getDestination()] = $service->export($data[$service->getSource()], false);
                $empty = false;

                if ($service->hasErrors()) {
                    $errors = $service->getErrors();
                    foreach ($errors as $error) {
                        Craft::error($error, __METHOD__);
                    }

                    return false;
                }
            }
        }

        foreach ($this->_settingsMigrationTypes as $key => $value) {
            $service = $plugin->get($value);
            if (array_key_exists($service->getSource(), $data)) {
                $migration['settings']['elements'][$service->getDestination()] = $service->export($data[$service->getSource()], true);
                $empty = false;

                if ($service->hasErrors()) {
                    $errors = $service->getErrors();
                    foreach ($errors as $error) {
                        Craft::error($error, __METHOD__);
                    }

                    return false;
                }
                $manifest = array_merge($manifest, [$key => $service->getManifest()]);
            }
        }

        if ($empty) {
            $migration = null;
        }

        if (array_key_exists('migrationName', $data)){
            $migrationName = trim($data['migrationName']);
            $migrationName = str_replace(' ', '_', $migrationName);
        } else {
            $migrationName = '';
        }

        $this->createMigration($migration, $manifest, $migrationName);

        return true;
    }
public function createSettingMigration ( $ data ) { $ manifest = [ ] ; $ migration = array ( 'settings' => array ( 'dependencies' => array ( ) , 'elements' => array ( ) , ) , ) ; $ empty = true ; //build a list of dependencies first to avoid potential cases where items are requested by fields before being created //export them without additional fields to prevent conflicts with missing fields, field tabs can be added on the second pass //after all the fields have been created $ plugin = MigrationManager :: getInstance ( ) ; foreach ( $ this -> _settingsDependencyTypes as $ key => $ value ) { $ service = $ plugin -> get ( $ value ) ; if ( array_key_exists ( $ service -> getSource ( ) , $ data ) ) { $ migration [ 'settings' ] [ 'dependencies' ] [ $ service -> getDestination ( ) ] = $ service -> export ( $ data [ $ service -> getSource ( ) ] , false ) ; $ empty = false ; if ( $ service -> hasErrors ( ) ) { $ errors = $ service -> getErrors ( ) ; foreach ( $ errors as $ error ) { Craft :: error ( $ error , __METHOD__ ) ; } return false ; } } } foreach ( $ this -> _settingsMigrationTypes as $ key => $ value ) { $ service = $ plugin -> get ( $ value ) ; if ( array_key_exists ( $ service -> getSource ( ) , $ data ) ) { $ migration [ 'settings' ] [ 'elements' ] [ $ service -> getDestination ( ) ] = $ service -> export ( $ data [ $ service -> getSource ( ) ] , true ) ; $ empty = false ; if ( $ service -> hasErrors ( ) ) { $ errors = $ service -> getErrors ( ) ; foreach ( $ errors as $ error ) { Craft :: error ( $ error , __METHOD__ ) ; } return false ; } $ manifest = array_merge ( $ manifest , [ $ key => $ service -> getManifest ( ) ] ) ; } } if ( $ empty ) { $ migration = null ; } if ( array_key_exists ( 'migrationName' , $ data ) ) { $ migrationName = trim ( $ data [ 'migrationName' ] ) ; $ migrationName = str_replace ( ' ' , '_' , $ migrationName ) ; } else { $ migrationName = '' ; } $ this -> createMigration ( $ migration , $ manifest , $ migrationName ) ; return true ; }
create a new migration file based on input element types

@param $data

@return bool
create a new migration file based on input element types