public function generateRenamedModels()
    {
        $addedModels = array_diff($this->newModelKeys, $this->oldModelKeys);

        /* @var $modelState ModelState */
        foreach ($addedModels as $addedModel) {
            $modelState = $this->toState->getModelState($addedModel);
            $meta = $this->newRegistry->getModel($addedModel)->getMeta();
            $modelDefinitionList = $this->getFieldsDefinitions(
                $modelState->fields
            );

            $removedModels = array_diff(
                $this->oldModelKeys,
                $this->newModelKeys
            );
            foreach ($removedModels as $removedModel) {
                $remModelState = $this->fromState->getModelState($removedModel);
                $remModelDefinitionList = $this->getFieldsDefinitions(
                    $remModelState->fields
                );

                if ($remModelDefinitionList == $modelDefinitionList) {
                    if (MigrationQuestion::hasModelRenamed(
                        $this->asker,
                        $removedModel,
                        $addedModel
                    )) {
                        $this->addOperation(
                            $meta->getAppName(),
                            RenameModel::createObject(
                                [
                                    'oldName' => $removedModel,
                                    'newName' => $addedModel,
                                ]
                            )
                        );

                        $this->renamedModels[$addedModel] = $removedModel;

                        // remove the old name and update with the new name.
                        $pos = array_search($removedModel, $this->oldModelKeys);

                        array_splice(
                            $this->oldModelKeys,
                            $pos,
                            1,
                            [$addedModel]
                        );

                        // you can stop here.
                        break;
                    }
                }
            }
        }
    }
public function generateRenamedModels()
    {
        $addedModels = array_diff($this->newModelKeys, $this->oldModelKeys);

        /* @var $modelState ModelState */
        foreach ($addedModels as $addedModel) {
            $modelState = $this->toState->getModelState($addedModel);
            $meta = $this->newRegistry->getModel($addedModel)->getMeta();
            $modelDefinitionList = $this->getFieldsDefinitions(
                $modelState->fields
            );

            $removedModels = array_diff(
                $this->oldModelKeys,
                $this->newModelKeys
            );
            foreach ($removedModels as $removedModel) {
                $remModelState = $this->fromState->getModelState($removedModel);
                $remModelDefinitionList = $this->getFieldsDefinitions(
                    $remModelState->fields
                );

                if ($remModelDefinitionList == $modelDefinitionList) {
                    if (MigrationQuestion::hasModelRenamed(
                        $this->asker,
                        $removedModel,
                        $addedModel
                    )) {
                        $this->addOperation(
                            $meta->getAppName(),
                            RenameModel::createObject(
                                [
                                    'oldName' => $removedModel,
                                    'newName' => $addedModel,
                                ]
                            )
                        );

                        $this->renamedModels[$addedModel] = $removedModel;

                        // remove the old name and update with the new name.
                        $pos = array_search($removedModel, $this->oldModelKeys);

                        array_splice(
                            $this->oldModelKeys,
                            $pos,
                            1,
                            [$addedModel]
                        );

                        // you can stop here.
                        break;
                    }
                }
            }
        }
    }
public function generateRenamedModels ( ) { $ addedModels = array_diff ( $ this -> newModelKeys , $ this -> oldModelKeys ) ; /* @var $modelState ModelState */ foreach ( $ addedModels as $ addedModel ) { $ modelState = $ this -> toState -> getModelState ( $ addedModel ) ; $ meta = $ this -> newRegistry -> getModel ( $ addedModel ) -> getMeta ( ) ; $ modelDefinitionList = $ this -> getFieldsDefinitions ( $ modelState -> fields ) ; $ removedModels = array_diff ( $ this -> oldModelKeys , $ this -> newModelKeys ) ; foreach ( $ removedModels as $ removedModel ) { $ remModelState = $ this -> fromState -> getModelState ( $ removedModel ) ; $ remModelDefinitionList = $ this -> getFieldsDefinitions ( $ remModelState -> fields ) ; if ( $ remModelDefinitionList == $ modelDefinitionList ) { if ( MigrationQuestion :: hasModelRenamed ( $ this -> asker , $ removedModel , $ addedModel ) ) { $ this -> addOperation ( $ meta -> getAppName ( ) , RenameModel :: createObject ( [ 'oldName' => $ removedModel , 'newName' => $ addedModel , ] ) ) ; $ this -> renamedModels [ $ addedModel ] = $ removedModel ; // remove the old name and update with the new name. $ pos = array_search ( $ removedModel , $ this -> oldModelKeys ) ; array_splice ( $ this -> oldModelKeys , $ pos , 1 , [ $ addedModel ] ) ; // you can stop here. break ; } } } } }
Finds any renamed models, and generates the operations for them, and removes the old entry from the model lists.
Must be run before other model-level generation.

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
Finds any renamed models and generates the operations for them and removes the old entry from the model lists . Must be run before other model - level generation .