annotate core/modules/migrate/src/Plugin/MigrateDestinationPluginManager.php @ 0:4c8ae668cc8c

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