public function processFieldsChangeType(ContentTypeInterface $contentType, $fieldTypes)
    {
        foreach ($contentType->getFields() as $field) {
            if (!isset($fieldTypes[$field->getId()])) {
                continue;
            }
            if ($fieldTypes[$field->getId()] == $field->getType()) {
                continue;
            }

            $this->om->remove($field);

            $fieldClass = $this->configurationManager->getEntityClass('field');
            $newField = new $fieldClass;
            $newField->setType($field->getType());
            $newField->setContentType($field->getContentType());
            $newField->setName($field->getName());
            $newField->setSlug($field->getSlug());
            $newField->setRequired($field->isRequired());
            $newField->setSortOrder($field->getSortOrder());
            $newField->setOptions($field->getOptions());
            $newField->setHint($field->getHint());
            $this->om->persist($newField);
        }
    }
public function processFieldsChangeType(ContentTypeInterface $contentType, $fieldTypes)
    {
        foreach ($contentType->getFields() as $field) {
            if (!isset($fieldTypes[$field->getId()])) {
                continue;
            }
            if ($fieldTypes[$field->getId()] == $field->getType()) {
                continue;
            }

            $this->om->remove($field);

            $fieldClass = $this->configurationManager->getEntityClass('field');
            $newField = new $fieldClass;
            $newField->setType($field->getType());
            $newField->setContentType($field->getContentType());
            $newField->setName($field->getName());
            $newField->setSlug($field->getSlug());
            $newField->setRequired($field->isRequired());
            $newField->setSortOrder($field->getSortOrder());
            $newField->setOptions($field->getOptions());
            $newField->setHint($field->getHint());
            $this->om->persist($newField);
        }
    }
public function processFieldsChangeType ( ContentTypeInterface $ contentType , $ fieldTypes ) { foreach ( $ contentType -> getFields ( ) as $ field ) { if ( ! isset ( $ fieldTypes [ $ field -> getId ( ) ] ) ) { continue ; } if ( $ fieldTypes [ $ field -> getId ( ) ] == $ field -> getType ( ) ) { continue ; } $ this -> om -> remove ( $ field ) ; $ fieldClass = $ this -> configurationManager -> getEntityClass ( 'field' ) ; $ newField = new $ fieldClass ; $ newField -> setType ( $ field -> getType ( ) ) ; $ newField -> setContentType ( $ field -> getContentType ( ) ) ; $ newField -> setName ( $ field -> getName ( ) ) ; $ newField -> setSlug ( $ field -> getSlug ( ) ) ; $ newField -> setRequired ( $ field -> isRequired ( ) ) ; $ newField -> setSortOrder ( $ field -> getSortOrder ( ) ) ; $ newField -> setOptions ( $ field -> getOptions ( ) ) ; $ newField -> setHint ( $ field -> getHint ( ) ) ; $ this -> om -> persist ( $ newField ) ; } }
When field type has changed, remove it and create new one
By cascading, will also remove associated fieldValues

@param ContentTypeInterface $contentType
@param array                $fieldTypes
When field type has changed remove it and create new one By cascading will also remove associated fieldValues