Mercurial > hg > isophonics-drupal-site
comparison core/modules/migrate/src/Plugin/MigratePluginManager.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\migrate\Plugin; | |
4 | |
5 use Drupal\Component\Plugin\Factory\DefaultFactory; | |
6 use Drupal\Core\Cache\CacheBackendInterface; | |
7 use Drupal\Core\Extension\ModuleHandlerInterface; | |
8 use Drupal\Core\Plugin\DefaultPluginManager; | |
9 | |
10 /** | |
11 * Manages migrate plugins. | |
12 * | |
13 * @see hook_migrate_info_alter() | |
14 * @see \Drupal\migrate\Annotation\MigrateSource | |
15 * @see \Drupal\migrate\Plugin\MigrateSourceInterface | |
16 * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase | |
17 * @see \Drupal\migrate\Annotation\MigrateProcessPlugin | |
18 * @see \Drupal\migrate\Plugin\MigrateProcessInterface | |
19 * @see \Drupal\migrate\Plugin\migrate\process\ProcessPluginBase | |
20 * @see plugin_api | |
21 * | |
22 * @ingroup migration | |
23 */ | |
24 class MigratePluginManager extends DefaultPluginManager implements MigratePluginManagerInterface { | |
25 | |
26 /** | |
27 * Constructs a MigratePluginManager object. | |
28 * | |
29 * @param string $type | |
30 * The type of the plugin: row, source, process, destination, entity_field, | |
31 * id_map. | |
32 * @param \Traversable $namespaces | |
33 * An object that implements \Traversable which contains the root paths | |
34 * keyed by the corresponding namespace to look for plugin implementations. | |
35 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend | |
36 * Cache backend instance to use. | |
37 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler | |
38 * The module handler to invoke the alter hook with. | |
39 * @param string $annotation | |
40 * (optional) The annotation class name. Defaults to | |
41 * 'Drupal\Component\Annotation\PluginID'. | |
42 */ | |
43 public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, $annotation = 'Drupal\Component\Annotation\PluginID') { | |
44 parent::__construct("Plugin/migrate/$type", $namespaces, $module_handler, NULL, $annotation); | |
45 $this->alterInfo('migrate_' . $type . '_info'); | |
46 $this->setCacheBackend($cache_backend, 'migrate_plugins_' . $type); | |
47 } | |
48 | |
49 /** | |
50 * {@inheritdoc} | |
51 */ | |
52 public function createInstance($plugin_id, array $configuration = [], MigrationInterface $migration = NULL) { | |
53 $plugin_definition = $this->getDefinition($plugin_id); | |
54 $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); | |
55 // If the plugin provides a factory method, pass the container to it. | |
56 if (is_subclass_of($plugin_class, 'Drupal\Core\Plugin\ContainerFactoryPluginInterface')) { | |
57 $plugin = $plugin_class::create(\Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition, $migration); | |
58 } | |
59 else { | |
60 $plugin = new $plugin_class($configuration, $plugin_id, $plugin_definition, $migration); | |
61 } | |
62 return $plugin; | |
63 } | |
64 | |
65 } |