Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\migrate\Plugin;
|
Chris@0
|
4
|
Chris@0
|
5 use Drupal\Core\Cache\CacheBackendInterface;
|
Chris@18
|
6 use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
|
Chris@18
|
7 use Drupal\Core\Entity\EntityTypeManagerInterface;
|
Chris@0
|
8 use Drupal\Core\Extension\ModuleHandlerInterface;
|
Chris@0
|
9
|
Chris@0
|
10 /**
|
Chris@0
|
11 * Plugin manager for migrate destination plugins.
|
Chris@0
|
12 *
|
Chris@0
|
13 * @see \Drupal\migrate\Plugin\MigrateDestinationInterface
|
Chris@16
|
14 * @see \Drupal\migrate\Plugin\migrate\destination\DestinationBase
|
Chris@0
|
15 * @see \Drupal\migrate\Annotation\MigrateDestination
|
Chris@0
|
16 * @see plugin_api
|
Chris@0
|
17 *
|
Chris@0
|
18 * @ingroup migration
|
Chris@0
|
19 */
|
Chris@0
|
20 class MigrateDestinationPluginManager extends MigratePluginManager {
|
Chris@18
|
21 use DeprecatedServicePropertyTrait;
|
Chris@0
|
22
|
Chris@0
|
23 /**
|
Chris@18
|
24 * {@inheritdoc}
|
Chris@18
|
25 */
|
Chris@18
|
26 protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
|
Chris@18
|
27
|
Chris@18
|
28 /**
|
Chris@18
|
29 * The entity type manager.
|
Chris@0
|
30 *
|
Chris@18
|
31 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
|
Chris@0
|
32 */
|
Chris@18
|
33 protected $entityTypeManager;
|
Chris@0
|
34
|
Chris@0
|
35 /**
|
Chris@0
|
36 * Constructs a MigrateDestinationPluginManager object.
|
Chris@0
|
37 *
|
Chris@0
|
38 * @param string $type
|
Chris@0
|
39 * The type of the plugin: row, source, process, destination, entity_field,
|
Chris@0
|
40 * id_map.
|
Chris@0
|
41 * @param \Traversable $namespaces
|
Chris@0
|
42 * An object that implements \Traversable which contains the root paths
|
Chris@0
|
43 * keyed by the corresponding namespace to look for plugin implementations.
|
Chris@0
|
44 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
|
Chris@0
|
45 * Cache backend instance to use.
|
Chris@0
|
46 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
Chris@0
|
47 * The module handler to invoke the alter hook with.
|
Chris@18
|
48 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
|
Chris@18
|
49 * The entity type manager.
|
Chris@0
|
50 * @param string $annotation
|
Chris@0
|
51 * (optional) The annotation class name. Defaults to
|
Chris@0
|
52 * 'Drupal\migrate\Annotation\MigrateDestination'.
|
Chris@0
|
53 */
|
Chris@18
|
54 public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityTypeManagerInterface $entity_type_manager, $annotation = 'Drupal\migrate\Annotation\MigrateDestination') {
|
Chris@0
|
55 parent::__construct($type, $namespaces, $cache_backend, $module_handler, $annotation);
|
Chris@18
|
56 $this->entityTypeManager = $entity_type_manager;
|
Chris@0
|
57 }
|
Chris@0
|
58
|
Chris@0
|
59 /**
|
Chris@0
|
60 * {@inheritdoc}
|
Chris@0
|
61 *
|
Chris@0
|
62 * A specific createInstance method is necessary to pass the migration on.
|
Chris@0
|
63 */
|
Chris@0
|
64 public function createInstance($plugin_id, array $configuration = [], MigrationInterface $migration = NULL) {
|
Chris@18
|
65 if (substr($plugin_id, 0, 7) == 'entity:' && !$this->entityTypeManager->getDefinition(substr($plugin_id, 7), FALSE)) {
|
Chris@0
|
66 $plugin_id = 'null';
|
Chris@0
|
67 }
|
Chris@0
|
68 return parent::createInstance($plugin_id, $configuration, $migration);
|
Chris@0
|
69 }
|
Chris@0
|
70
|
Chris@0
|
71 }
|