class MigrateEntity

Same name in other branches
  1. 9 core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php \Drupal\migrate\Plugin\Derivative\MigrateEntity
  2. 8.9.x core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php \Drupal\migrate\Plugin\Derivative\MigrateEntity
  3. 10 core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php \Drupal\migrate\Plugin\Derivative\MigrateEntity

Hierarchy

Expanded class hierarchy of MigrateEntity

1 file declares its use of MigrateEntity
Entity.php in core/modules/migrate/src/Plugin/migrate/destination/Entity.php

File

core/modules/migrate/src/Plugin/Derivative/MigrateEntity.php, line 8

Namespace

Drupal\migrate\Plugin\Derivative
View source
class MigrateEntity implements ContainerDeriverInterface {
    
    /**
     * List of derivative definitions.
     *
     * @var array
     */
    protected $derivatives = [];
    
    /**
     * The entity definitions.
     *
     * @var \Drupal\Core\Entity\EntityTypeInterface[]
     */
    protected $entityDefinitions;
    
    /**
     * Constructs a MigrateEntity object.
     *
     * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_definitions
     *   A list of entity definition objects.
     */
    public function __construct(array $entity_definitions) {
        $this->entityDefinitions = $entity_definitions;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function create(ContainerInterface $container, $base_plugin_id) {
        return new static($container->get('entity_type.manager')
            ->getDefinitions());
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
        if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) {
            return $this->derivatives[$derivative_id];
        }
        $this->getDerivativeDefinitions($base_plugin_definition);
        return $this->derivatives[$derivative_id];
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDerivativeDefinitions($base_plugin_definition) {
        foreach ($this->entityDefinitions as $entity_type => $entity_info) {
            $class = is_subclass_of($entity_info->getClass(), 'Drupal\\Core\\Config\\Entity\\ConfigEntityInterface') ? 'Drupal\\migrate\\Plugin\\migrate\\destination\\EntityConfigBase' : 'Drupal\\migrate\\Plugin\\migrate\\destination\\EntityContentBase';
            $this->derivatives[$entity_type] = [
                'id' => "entity:{$entity_type}",
                'class' => $class,
                'requirements_met' => 1,
                'provider' => $entity_info->getProvider(),
            ];
        }
        return $this->derivatives;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
MigrateEntity::$derivatives protected property List of derivative definitions.
MigrateEntity::$entityDefinitions protected property The entity definitions.
MigrateEntity::create public static function Creates a new class instance. Overrides ContainerDeriverInterface::create
MigrateEntity::getDerivativeDefinition public function Gets the definition of a derivative plugin. Overrides DeriverInterface::getDerivativeDefinition
MigrateEntity::getDerivativeDefinitions public function Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface::getDerivativeDefinitions 1
MigrateEntity::__construct public function Constructs a MigrateEntity object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.