|
@@ -2,11 +2,14 @@
|
|
|
|
|
|
namespace Drupal\reinstall\Plugin\migrate\source;
|
|
|
|
|
|
+use Drupal\Component\Plugin\ConfigurablePluginInterface;
|
|
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
|
|
use Drupal\migrate\MigrateException;
|
|
|
use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
|
|
|
use Drupal\migrate\Plugin\MigrationInterface;
|
|
|
use Drupal\migrate\Row;
|
|
|
+use Drupal\reinstall\ReinstallEvents;
|
|
|
+use Drupal\reinstall\SourceEvent;
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
@@ -20,7 +23,7 @@ use Symfony\Component\Yaml\Yaml;
|
|
|
* id = "reinstall_base"
|
|
|
* )
|
|
|
*/
|
|
|
-class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPluginInterface {
|
|
|
+class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPluginInterface, ConfigurablePluginInterface {
|
|
|
use SimpleSourceTrait;
|
|
|
|
|
|
/**
|
|
@@ -49,6 +52,7 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
|
|
|
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
|
|
$this->eventDispatcher = $eventDispatcher;
|
|
|
$this->records = array_map([$this, 'flattenRecord'], $this->initialParse($configuration));
|
|
|
+ $eventDispatcher->dispatch(ReinstallEvents::POST_SOURCE_PARSE, new SourceEvent($this));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -193,4 +197,60 @@ class ReinstallSourceBase extends SourcePluginBase implements ContainerFactoryPl
|
|
|
return $ret;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets this plugin's configuration.
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ * An array of this plugin's configuration.
|
|
|
+ */
|
|
|
+ public function getConfiguration() {
|
|
|
+ return $this->configuration;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the configuration for this plugin instance.
|
|
|
+ *
|
|
|
+ * @param array $configuration
|
|
|
+ * An associative array containing the plugin's configuration.
|
|
|
+ */
|
|
|
+ public function setConfiguration(array $configuration) {
|
|
|
+ $this->configuration = $configuration;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets default configuration for this plugin.
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ * An associative array with the default configuration.
|
|
|
+ */
|
|
|
+ public function defaultConfiguration() {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Calculates dependencies for the configured plugin.
|
|
|
+ *
|
|
|
+ * Dependencies are saved in the plugin's configuration entity and are used to
|
|
|
+ * determine configuration synchronization order. For example, if the plugin
|
|
|
+ * integrates with specific user roles, this method should return an array of
|
|
|
+ * dependencies listing the specified roles.
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ * An array of dependencies grouped by type (config, content, module,
|
|
|
+ * theme). For example:
|
|
|
+ * @code
|
|
|
+ * array(
|
|
|
+ * 'config' => array('user.role.anonymous', 'user.role.authenticated'),
|
|
|
+ * 'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'),
|
|
|
+ * 'module' => array('node', 'user'),
|
|
|
+ * 'theme' => array('seven'),
|
|
|
+ * );
|
|
|
+ * @endcode
|
|
|
+ *
|
|
|
+ * @see \Drupal\Core\Config\Entity\ConfigDependencyManager
|
|
|
+ * @see \Drupal\Core\Entity\EntityInterface::getConfigDependencyName()
|
|
|
+ */
|
|
|
+ public function calculateDependencies() {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
}
|