Same name in other branches
  1. 2.x src/EntityClone/Config/FieldConfigEntityClone.php \Drupal\entity_clone\EntityClone\Config\FieldConfigEntityClone

Class Field Config Entity Clone.

Hierarchy

Expanded class hierarchy of FieldConfigEntityClone

1 file declares its use of FieldConfigEntityClone
entity_clone.module in ./entity_clone.module
Contains entity_clone.module.

File

src/EntityClone/Config/FieldConfigEntityClone.php, line 10

Namespace

Drupal\entity_clone\EntityClone\Config
View source
class FieldConfigEntityClone extends ConfigEntityCloneBase {
    
    /**
     * {@inheritdoc}
     */
    public function cloneEntity(EntityInterface $field_config, EntityInterface $cloned_field_config, array $properties = []) {
        
        /** @var \Drupal\field\Entity\FieldConfig $field_config */
        
        /** @var \Drupal\field\Entity\FieldConfig $cloned_field_config */
        
        /** @var \Drupal\field\Entity\FieldStorageConfig $cloned_field_storage */
        if (!isset($properties['skip_storage']) || !$properties['skip_storage']) {
            $cloned_field_storage = $field_config->getFieldStorageDefinition()
                ->createDuplicate();
            $cloned_field_storage->set('field_name', $properties['id']);
            $cloned_field_storage->set('id', $properties['id'] . '.' . $cloned_field_storage->getTargetEntityTypeId());
            $cloned_field_storage->save();
        }
        unset($properties['skip_storage']);
        $properties['field_name'] = $properties['id'];
        $properties['id'] = $cloned_field_config->getTargetEntityTypeId() . '.' . $cloned_field_config->getTargetBundle() . '.' . $properties['id'];
        return parent::cloneEntity($field_config, $cloned_field_config, $properties);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ConfigEntityCloneBase::$entityTypeId protected property The entity type ID.
ConfigEntityCloneBase::$entityTypeManager protected property The entity type manager.
ConfigEntityCloneBase::createInstance public static function 1
ConfigEntityCloneBase::__construct public function Constructs a new ConfigEntityCloneBase. 1
FieldConfigEntityClone::cloneEntity public function Clone an entity. Overrides ConfigEntityCloneBase::cloneEntity