MigrateEntityRevision.php in Drupal 10
File
core/modules/migrate/src/Plugin/Derivative/MigrateEntityRevision.php
View source
<?php
namespace Drupal\migrate\Plugin\Derivative;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MigrateEntityRevision implements ContainerDeriverInterface {
protected $derivatives = [];
protected $entityDefinitions;
public function __construct(array $entity_definitions) {
$this->entityDefinitions = $entity_definitions;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager')
->getDefinitions());
}
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];
}
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityDefinitions as $entity_type => $entity_info) {
if ($entity_info
->getKey('revision')) {
$this->derivatives[$entity_type] = [
'id' => "entity_revision:{$entity_type}",
'class' => 'Drupal\\migrate\\Plugin\\migrate\\destination\\EntityRevision',
'requirements_met' => 1,
'provider' => $entity_info
->getProvider(),
];
}
}
return $this->derivatives;
}
}