public function generateRenamedFields()
    {
        /* @var $oldModelState ModelState */
        /* @var $field Field */
        foreach ($this->keptModelKeys as $modelName) {
            $oldModelName = $this->getOldModelName($modelName);
            $meta = $this->newRegistry
                ->getModel($modelName)->getMeta();
            $oldModelState = $this->fromState->getModelState($oldModelName);

            $newModel = $this->newRegistry->getModel($modelName);

            $oldFieldKeys = $this->oldFieldKeys[$modelName];
            $newFieldKeys = $this->newFieldKeys[$modelName];

            $addedFields = array_diff($newFieldKeys, $oldFieldKeys);

            foreach ($addedFields as $addedField) {
                $field = $newModel->getMeta()->getField($addedField);
                $fieldDef = $this->deepDeconstruct($field);

                $removedFields = array_diff($oldFieldKeys, $newFieldKeys);
                foreach ($removedFields as $remField) {
                    $oldFieldDef = $this->deepDeconstruct(
                        $oldModelState->getFieldByName($remField)
                    );

                    if (!is_null($field->relation) &&
                        !is_null($field->relation->toModel) &&
                        isset($oldFieldDef['constructorArgs']['to'])
                    ) {
                        $oldRelTo = $oldFieldDef['constructorArgs']['to'];
                        if (in_array($oldRelTo, $this->renamedModels)) {
                            $oldFieldDef['constructorArgs']['to'] =
                                $this->getOldModelName($oldRelTo);
                        }
                    }

                    if ($fieldDef === $oldFieldDef) {
                        if (MigrationQuestion::hasFieldRenamed(
                            $this->asker,
                            $modelName,
                            $remField,
                            $addedField,
                            $field
                        )
                        ) {
                            $this->addOperation(
                                $meta->getAppName(),
                                RenameField::createObject(
                                    [
                                        'modelName' => $modelName,
                                        'oldName' => $remField,
                                        'newName' => $addedField,
                                    ]
                                )
                            );

                            // remove the old name and update with the new name.
                            $pos = array_search(
                                $remField,
                                $this->oldFieldKeys[$modelName]
                            );

                            array_splice(
                                $this->oldFieldKeys[$modelName],
                                $pos,
                                1,
                                [$addedField]
                            );
                            $this->renamedFields[$modelName][$addedField] = $remField;

                            break;
                        }
                    }
                }
            }
        }
    }
public function generateRenamedFields()
    {
        /* @var $oldModelState ModelState */
        /* @var $field Field */
        foreach ($this->keptModelKeys as $modelName) {
            $oldModelName = $this->getOldModelName($modelName);
            $meta = $this->newRegistry
                ->getModel($modelName)->getMeta();
            $oldModelState = $this->fromState->getModelState($oldModelName);

            $newModel = $this->newRegistry->getModel($modelName);

            $oldFieldKeys = $this->oldFieldKeys[$modelName];
            $newFieldKeys = $this->newFieldKeys[$modelName];

            $addedFields = array_diff($newFieldKeys, $oldFieldKeys);

            foreach ($addedFields as $addedField) {
                $field = $newModel->getMeta()->getField($addedField);
                $fieldDef = $this->deepDeconstruct($field);

                $removedFields = array_diff($oldFieldKeys, $newFieldKeys);
                foreach ($removedFields as $remField) {
                    $oldFieldDef = $this->deepDeconstruct(
                        $oldModelState->getFieldByName($remField)
                    );

                    if (!is_null($field->relation) &&
                        !is_null($field->relation->toModel) &&
                        isset($oldFieldDef['constructorArgs']['to'])
                    ) {
                        $oldRelTo = $oldFieldDef['constructorArgs']['to'];
                        if (in_array($oldRelTo, $this->renamedModels)) {
                            $oldFieldDef['constructorArgs']['to'] =
                                $this->getOldModelName($oldRelTo);
                        }
                    }

                    if ($fieldDef === $oldFieldDef) {
                        if (MigrationQuestion::hasFieldRenamed(
                            $this->asker,
                            $modelName,
                            $remField,
                            $addedField,
                            $field
                        )
                        ) {
                            $this->addOperation(
                                $meta->getAppName(),
                                RenameField::createObject(
                                    [
                                        'modelName' => $modelName,
                                        'oldName' => $remField,
                                        'newName' => $addedField,
                                    ]
                                )
                            );

                            // remove the old name and update with the new name.
                            $pos = array_search(
                                $remField,
                                $this->oldFieldKeys[$modelName]
                            );

                            array_splice(
                                $this->oldFieldKeys[$modelName],
                                $pos,
                                1,
                                [$addedField]
                            );
                            $this->renamedFields[$modelName][$addedField] = $remField;

                            break;
                        }
                    }
                }
            }
        }
    }
public function generateRenamedFields ( ) { /* @var $oldModelState ModelState */ /* @var $field Field */ foreach ( $ this -> keptModelKeys as $ modelName ) { $ oldModelName = $ this -> getOldModelName ( $ modelName ) ; $ meta = $ this -> newRegistry -> getModel ( $ modelName ) -> getMeta ( ) ; $ oldModelState = $ this -> fromState -> getModelState ( $ oldModelName ) ; $ newModel = $ this -> newRegistry -> getModel ( $ modelName ) ; $ oldFieldKeys = $ this -> oldFieldKeys [ $ modelName ] ; $ newFieldKeys = $ this -> newFieldKeys [ $ modelName ] ; $ addedFields = array_diff ( $ newFieldKeys , $ oldFieldKeys ) ; foreach ( $ addedFields as $ addedField ) { $ field = $ newModel -> getMeta ( ) -> getField ( $ addedField ) ; $ fieldDef = $ this -> deepDeconstruct ( $ field ) ; $ removedFields = array_diff ( $ oldFieldKeys , $ newFieldKeys ) ; foreach ( $ removedFields as $ remField ) { $ oldFieldDef = $ this -> deepDeconstruct ( $ oldModelState -> getFieldByName ( $ remField ) ) ; if ( ! is_null ( $ field -> relation ) && ! is_null ( $ field -> relation -> toModel ) && isset ( $ oldFieldDef [ 'constructorArgs' ] [ 'to' ] ) ) { $ oldRelTo = $ oldFieldDef [ 'constructorArgs' ] [ 'to' ] ; if ( in_array ( $ oldRelTo , $ this -> renamedModels ) ) { $ oldFieldDef [ 'constructorArgs' ] [ 'to' ] = $ this -> getOldModelName ( $ oldRelTo ) ; } } if ( $ fieldDef === $ oldFieldDef ) { if ( MigrationQuestion :: hasFieldRenamed ( $ this -> asker , $ modelName , $ remField , $ addedField , $ field ) ) { $ this -> addOperation ( $ meta -> getAppName ( ) , RenameField :: createObject ( [ 'modelName' => $ modelName , 'oldName' => $ remField , 'newName' => $ addedField , ] ) ) ; // remove the old name and update with the new name. $ pos = array_search ( $ remField , $ this -> oldFieldKeys [ $ modelName ] ) ; array_splice ( $ this -> oldFieldKeys [ $ modelName ] , $ pos , 1 , [ $ addedField ] ) ; $ this -> renamedFields [ $ modelName ] [ $ addedField ] = $ remField ; break ; } } } } } }
Works out renamed fields.

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
Works out renamed fields .