3 namespace Drupal\migrate\Plugin;
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Entity\EntityManagerInterface;
7 use Drupal\Core\Extension\ModuleHandlerInterface;
10 * Plugin manager for migrate destination plugins.
12 * @see \Drupal\migrate\Plugin\MigrateDestinationInterface
13 * @see \Drupal\migrate\Plugin\migrate\destination\DestinationBase
14 * @see \Drupal\migrate\Annotation\MigrateDestination
19 class MigrateDestinationPluginManager extends MigratePluginManager {
24 * @var \Drupal\Core\Entity\EntityManagerInterface
26 protected $entityManager;
29 * Constructs a MigrateDestinationPluginManager object.
32 * The type of the plugin: row, source, process, destination, entity_field,
34 * @param \Traversable $namespaces
35 * An object that implements \Traversable which contains the root paths
36 * keyed by the corresponding namespace to look for plugin implementations.
37 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
38 * Cache backend instance to use.
39 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
40 * The module handler to invoke the alter hook with.
41 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
43 * @param string $annotation
44 * (optional) The annotation class name. Defaults to
45 * 'Drupal\migrate\Annotation\MigrateDestination'.
47 public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager, $annotation = 'Drupal\migrate\Annotation\MigrateDestination') {
48 parent::__construct($type, $namespaces, $cache_backend, $module_handler, $annotation);
49 $this->entityManager = $entity_manager;
55 * A specific createInstance method is necessary to pass the migration on.
57 public function createInstance($plugin_id, array $configuration = [], MigrationInterface $migration = NULL) {
58 if (substr($plugin_id, 0, 7) == 'entity:' && !$this->entityManager->getDefinition(substr($plugin_id, 7), FALSE)) {
61 return parent::createInstance($plugin_id, $configuration, $migration);