Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\Derivative\MigrateEntity.
*/
namespace Drupal\migrate\Plugin\Derivative;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\Derivative\MigrateEntityRevision.
*/
namespace Drupal\migrate\Plugin\Derivative;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;

View file

@ -1,31 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateBuilderInterface.
*/
namespace Drupal\migrate\Plugin;
/**
* Defines the builder plugin type.
*
* Builder plugins implement custom logic to generate migration entities from
* migration templates. For example, a migration may need to be customized based
* on data that's present in the source database; such customization is
* implemented by builders.
*/
interface MigrateBuilderInterface {
/**
* Builds migration entities based on a template.
*
* @param array $template
* The parsed template.
*
* @return \Drupal\migrate\Entity\MigrationInterface[]
* The unsaved migrations generated from the template.
*/
public function buildMigrations(array $template);
}

View file

@ -1,14 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateDestinationInterface.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
/**
@ -48,7 +42,7 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
* @todo Review the cases where we need the Migration parameter, can we avoid
* that? To be resolved with https://www.drupal.org/node/2543568.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* (optional) The migration containing this destination. Defaults to NULL.
*
* @return array

View file

@ -1,16 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateDestinationPluginManager.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate\Entity\MigrationInterface;
/**
* Plugin manager for migrate destination plugins.

View file

@ -1,14 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateIdMapInterface.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateMessageInterface;
use Drupal\migrate\Row;

View file

@ -1,17 +1,11 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigratePluginManager.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\migrate\Entity\MigrationInterface;
/**
* Manages migrate plugins.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateProcessInterface.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\MigrateSourceInterface.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\migrate\Row;

View file

@ -0,0 +1,715 @@
<?php
namespace Drupal\migrate\Plugin;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\Component\Utility\NestedArray;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines the Migration plugin.
*
* The migration process plugin represents one single migration and acts like a
* container for the information about a single migration such as the source,
* process and destination plugins.
*/
class Migration extends PluginBase implements MigrationInterface, RequirementsInterface, ContainerFactoryPluginInterface {
/**
* The migration ID (machine name).
*
* @var string
*/
protected $id;
/**
* The human-readable label for the migration.
*
* @var string
*/
protected $label;
/**
* The plugin ID for the row.
*
* @var string
*/
protected $row;
/**
* The source configuration, with at least a 'plugin' key.
*
* Used to initialize the $sourcePlugin.
*
* @var array
*/
protected $source;
/**
* The source plugin.
*
* @var \Drupal\migrate\Plugin\MigrateSourceInterface
*/
protected $sourcePlugin;
/**
* The configuration describing the process plugins.
*
* This is a strictly internal property and should not returned to calling
* code, use getProcess() instead.
*
* @var array
*/
protected $process = [];
/**
* The cached process plugins.
*
* @var array
*/
protected $processPlugins = [];
/**
* The destination configuration, with at least a 'plugin' key.
*
* Used to initialize $destinationPlugin.
*
* @var array
*/
protected $destination;
/**
* The destination plugin.
*
* @var \Drupal\migrate\Plugin\MigrateDestinationInterface
*/
protected $destinationPlugin;
/**
* The identifier map data.
*
* Used to initialize $idMapPlugin.
*
* @var string
*/
protected $idMap = [];
/**
* The identifier map.
*
* @var \Drupal\migrate\Plugin\MigrateIdMapInterface
*/
protected $idMapPlugin;
/**
* The source identifiers.
*
* An array of source identifiers: the keys are the name of the properties,
* the values are dependent on the ID map plugin.
*
* @var array
*/
protected $sourceIds = [];
/**
* The destination identifiers.
*
* An array of destination identifiers: the keys are the name of the
* properties, the values are dependent on the ID map plugin.
*
* @var array
*/
protected $destinationIds = [];
/**
* Information on the property used as the high watermark.
*
* Array of 'name' & (optional) db 'alias' properties used for high watermark.
*
* @var array
*/
protected $highWaterProperty;
/**
* Indicate whether the primary system of record for this migration is the
* source, or the destination (Drupal). In the source case, migration of
* an existing object will completely replace the Drupal object with data from
* the source side. In the destination case, the existing Drupal object will
* be loaded, then changes from the source applied; also, rollback will not be
* supported.
*
* @var string
*/
protected $systemOfRecord = self::SOURCE;
/**
* Specify value of source_row_status for current map row. Usually set by
* MigrateFieldHandler implementations.
*
* @var int
*/
protected $sourceRowStatus = MigrateIdMapInterface::STATUS_IMPORTED;
/**
* @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
*/
protected $highWaterStorage;
/**
* Track time of last import if TRUE.
*
* @var bool
*/
protected $trackLastImported = FALSE;
/**
* These migrations must be already executed before this migration can run.
*
* @var array
*/
protected $requirements = [];
/**
* These migrations, if run, must be executed before this migration.
*
* These are different from the configuration dependencies. Migration
* dependencies are only used to store relationships between migrations.
*
* The migration_dependencies value is structured like this:
* @code
* array(
* 'required' => array(
* // An array of migration IDs that must be run before this migration.
* ),
* 'optional' => array(
* // An array of migration IDs that, if they exist, must be run before
* // this migration.
* ),
* );
* @endcode
*
* @var array
*/
protected $migration_dependencies = [];
/**
* The migration's configuration dependencies.
*
* These store any dependencies on modules or other configuration (including
* other migrations) that must be available before the migration can be
* created.
*
* @see \Drupal\Core\Config\Entity\ConfigDependencyManager
*
* @var array
*/
protected $dependencies = [];
/**
* The migration plugin manager for loading other migration plugins.
*
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
*/
protected $migrationPluginManager;
/**
* The source plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $sourcePluginManager;
/**
* Thep process plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $processPluginManager;
/**
* The destination plugin manager.
*
* @var \Drupal\migrate\Plugin\MigrateDestinationPluginManager
*/
protected $destinationPluginManager;
/**
* The ID map plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $idMapPluginManager;
/**
* Labels corresponding to each defined status.
*
* @var array
*/
protected $statusLabels = [
self::STATUS_IDLE => 'Idle',
self::STATUS_IMPORTING => 'Importing',
self::STATUS_ROLLING_BACK => 'Rolling back',
self::STATUS_STOPPING => 'Stopping',
self::STATUS_DISABLED => 'Disabled',
];
/**
* Constructs a Migration.
*
* @param array $configuration
* Plugin configuration.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
* The migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
* The source migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
* The process migration plugin manager.
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
* The destination migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
* The ID map migration plugin manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $source_plugin_manager, MigratePluginManager $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManager $idmap_plugin_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migrationPluginManager = $migration_plugin_manager;
$this->sourcePluginManager = $source_plugin_manager;
$this->processPluginManager = $process_plugin_manager;
$this->destinationPluginManager = $destination_plugin_manager;
$this->idMapPluginManager = $idmap_plugin_manager;
foreach ($plugin_definition as $key => $value) {
$this->$key = $value;
}
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('plugin.manager.migration'),
$container->get('plugin.manager.migrate.source'),
$container->get('plugin.manager.migrate.process'),
$container->get('plugin.manager.migrate.destination'),
$container->get('plugin.manager.migrate.id_map')
);
}
/**
* {@inheritdoc}
*/
public function id() {
return $this->pluginId;
}
/**
* {@inheritdoc}
*/
public function label() {
return $this->label;
}
/**
* Gets any arbitrary property's value.
*
* @param string $property
* The property to retrieve.
*
* @return mixed
* The value for that property, or NULL if the property does not exist.
*
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.x. Use
* more specific getters instead.
*/
public function get($property) {
return isset($this->$property) ? $this->$property : NULL;
}
/**
* Retrieves the ID map plugin.
*
* @return \Drupal\migrate\Plugin\MigrateIdMapInterface
* The ID map plugin.
*/
public function getIdMapPlugin() {
return $this->idMapPlugin;
}
/**
* {@inheritdoc}
*/
public function getSourcePlugin() {
if (!isset($this->sourcePlugin)) {
$this->sourcePlugin = $this->sourcePluginManager->createInstance($this->source['plugin'], $this->source, $this);
}
return $this->sourcePlugin;
}
/**
* {@inheritdoc}
*/
public function getProcessPlugins(array $process = NULL) {
if (!isset($process)) {
$process = $this->getProcess();
}
$index = serialize($process);
if (!isset($this->processPlugins[$index])) {
$this->processPlugins[$index] = array();
foreach ($this->getProcessNormalized($process) as $property => $configurations) {
$this->processPlugins[$index][$property] = array();
foreach ($configurations as $configuration) {
if (isset($configuration['source'])) {
$this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance('get', $configuration, $this);
}
// Get is already handled.
if ($configuration['plugin'] != 'get') {
$this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance($configuration['plugin'], $configuration, $this);
}
if (!$this->processPlugins[$index][$property]) {
throw new MigrateException("Invalid process configuration for $property");
}
}
}
}
return $this->processPlugins[$index];
}
/**
* Resolve shorthands into a list of plugin configurations.
*
* @param array $process
* A process configuration array.
*
* @return array
* The normalized process configuration.
*/
protected function getProcessNormalized(array $process) {
$normalized_configurations = array();
foreach ($process as $destination => $configuration) {
if (is_string($configuration)) {
$configuration = array(
'plugin' => 'get',
'source' => $configuration,
);
}
if (isset($configuration['plugin'])) {
$configuration = array($configuration);
}
$normalized_configurations[$destination] = $configuration;
}
return $normalized_configurations;
}
/**
* {@inheritdoc}
*/
public function getDestinationPlugin($stub_being_requested = FALSE) {
if ($stub_being_requested && !empty($this->destination['no_stub'])) {
throw new MigrateSkipRowException;
}
if (!isset($this->destinationPlugin)) {
$this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
}
return $this->destinationPlugin;
}
/**
* {@inheritdoc}
*/
public function getIdMap() {
if (!isset($this->idMapPlugin)) {
$configuration = $this->idMap;
$plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql';
$this->idMapPlugin = $this->idMapPluginManager->createInstance($plugin, $configuration, $this);
}
return $this->idMapPlugin;
}
/**
* Get the high water storage object.
*
* @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface
* The storage object.
*/
protected function getHighWaterStorage() {
if (!isset($this->highWaterStorage)) {
$this->highWaterStorage = \Drupal::keyValue('migrate:high_water');
}
return $this->highWaterStorage;
}
/**
* {@inheritdoc}
*/
public function getHighWater() {
return $this->getHighWaterStorage()->get($this->id());
}
/**
* {@inheritdoc}
*/
public function saveHighWater($high_water) {
$this->getHighWaterStorage()->set($this->id(), $high_water);
}
/**
* {@inheritdoc}
*/
public function checkRequirements() {
// Check whether the current migration source and destination plugin
// requirements are met or not.
if ($this->getSourcePlugin() instanceof RequirementsInterface) {
$this->getSourcePlugin()->checkRequirements();
}
if ($this->getDestinationPlugin() instanceof RequirementsInterface) {
$this->getDestinationPlugin()->checkRequirements();
}
if (empty($this->requirements)) {
// There are no requirements to check.
return;
}
/** @var \Drupal\migrate\Plugin\MigrationInterface[] $required_migrations */
$required_migrations = $this->getMigrationPluginManager()->createInstances($this->requirements);
$missing_migrations = array_diff($this->requirements, array_keys($required_migrations));
// Check if the dependencies are in good shape.
foreach ($required_migrations as $migration_id => $required_migration) {
if (!$required_migration->allRowsProcessed()) {
$missing_migrations[] = $migration_id;
}
}
if ($missing_migrations) {
throw new RequirementsException('Missing migrations ' . implode(', ', $missing_migrations) . '.', ['requirements' => $missing_migrations]);
}
}
/**
* Gets the migration plugin manager.
*
* @return \Drupal\migrate\Plugin\MigratePluginManager
* The plugin manager.
*/
protected function getMigrationPluginManager() {
return $this->migrationPluginManager;
}
/**
* {@inheritdoc}
*/
public function setStatus($status) {
\Drupal::keyValue('migrate_status')->set($this->id(), $status);
}
/**
* {@inheritdoc}
*/
public function getStatus() {
return \Drupal::keyValue('migrate_status')->get($this->id(), static::STATUS_IDLE);
}
/**
* {@inheritdoc}
*/
public function getStatusLabel() {
$status = $this->getStatus();
if (isset($this->statusLabels[$status])) {
return $this->statusLabels[$status];
}
else {
return '';
}
}
/**
* {@inheritdoc}
*/
public function getInterruptionResult() {
return \Drupal::keyValue('migrate_interruption_result')->get($this->id(), static::RESULT_INCOMPLETE);
}
/**
* {@inheritdoc}
*/
public function clearInterruptionResult() {
\Drupal::keyValue('migrate_interruption_result')->delete($this->id());
}
/**
* {@inheritdoc}
*/
public function interruptMigration($result) {
$this->setStatus(MigrationInterface::STATUS_STOPPING);
\Drupal::keyValue('migrate_interruption_result')->set($this->id(), $result);
}
/**
* {@inheritdoc}
*/
public function allRowsProcessed() {
$source_count = $this->getSourcePlugin()->count();
// If the source is uncountable, we have no way of knowing if it's
// complete, so stipulate that it is.
if ($source_count < 0) {
return TRUE;
}
$processed_count = $this->getIdMap()->processedCount();
// We don't use == because in some circumstances (like unresolved stubs
// being created), the processed count may be higher than the available
// source rows.
return $source_count <= $processed_count;
}
/**
* {@inheritdoc}
*/
public function set($property_name, $value) {
if ($property_name == 'source') {
// Invalidate the source plugin.
unset($this->sourcePlugin);
}
elseif ($property_name === 'destination') {
// Invalidate the destination plugin.
unset($this->destinationPlugin);
}
$this->{$property_name} = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function getProcess() {
return $this->getProcessNormalized($this->process);
}
/**
* {@inheritdoc}
*/
public function setProcess(array $process) {
$this->process = $process;
return $this;
}
/**
* {@inheritdoc}
*/
public function setProcessOfProperty($property, $process_of_property) {
$this->process[$property] = $process_of_property;
return $this;
}
/**
* {@inheritdoc}
*/
public function mergeProcessOfProperty($property, array $process_of_property) {
// If we already have a process value then merge the incoming process array
//otherwise simply set it.
$current_process = $this->getProcess();
if (isset($current_process[$property])) {
$this->process = NestedArray::mergeDeepArray([$current_process, $this->getProcessNormalized([$property => $process_of_property])], TRUE);
}
else {
$this->setProcessOfProperty($property, $process_of_property);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function getSystemOfRecord() {
return $this->systemOfRecord;
}
/**
* {@inheritdoc}
*/
public function setSystemOfRecord($system_of_record) {
$this->systemOfRecord = $system_of_record;
return $this;
}
/**
* {@inheritdoc}
*/
public function isTrackLastImported() {
return $this->trackLastImported;
}
/**
* {@inheritdoc}
*/
public function setTrackLastImported($track_last_imported) {
$this->trackLastImported = (bool) $track_last_imported;
return $this;
}
/**
* {@inheritdoc}
*/
public function getMigrationDependencies() {
return $this->migration_dependencies + ['required' => [], 'optional' => []];
}
/**
* {@inheritdoc}
*/
public function getPluginDefinition() {
$definition = [];
// While normal plugins do not change their definitions on the fly, this
// one does so accommodate for that.
foreach (parent::getPluginDefinition() as $key => $value) {
$definition[$key] = isset($this->$key) ? $this->$key : $value;
}
return $definition;
}
/**
* {@inheritdoc}
*/
public function getDestinationConfiguration() {
return $this->destination;
}
/**
* {@inheritdoc}
*/
public function getSourceConfiguration() {
return $this->source;
}
/**
* {@inheritdoc}
*/
public function getHighWaterProperty() {
return $this->highWaterProperty;
}
/**
* {@inheritdoc}
*/
public function getTrackLastImported() {
$this->trackLastImported;
}
/**
* {@inheritdoc}
*/
public function getDestinationIds() {
$this->destinationIds;
}
}

View file

@ -0,0 +1,32 @@
<?php
namespace Drupal\migrate\Plugin;
/**
* Provides functionality for migration derivers.
*/
trait MigrationDeriverTrait {
/**
* Returns a fully initialized instance of a source plugin.
*
* @param string $source_plugin_id
* The source plugin ID.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface
* The fully initialized source plugin.
*/
public static function getSourcePlugin($source_plugin_id) {
$definition = [
'source' => [
'ignore_map' => TRUE,
'plugin' => $source_plugin_id,
],
'destination' => [
'plugin' => 'null',
],
];
return \Drupal::service('plugin.manager.migration')->createStubMigration($definition)->getSourcePlugin();
}
}

View file

@ -0,0 +1,377 @@
<?php
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
/**
* Interface for migrations.
*/
interface MigrationInterface extends PluginInspectionInterface, DerivativeInspectionInterface {
/**
* A constant used for systemOfRecord.
*/
const SOURCE = 'source';
/**
* A constant used for systemOfRecord.
*/
const DESTINATION = 'destination';
/**
* The migration is currently not running.
*/
const STATUS_IDLE = 0;
/**
* The migration is currently importing.
*/
const STATUS_IMPORTING = 1;
/**
* The migration is currently being rolled back.
*/
const STATUS_ROLLING_BACK = 2;
/**
* The migration is being stopped.
*/
const STATUS_STOPPING = 3;
/**
* The migration has been disabled.
*/
const STATUS_DISABLED = 4;
/**
* Migration error.
*/
const MESSAGE_ERROR = 1;
/**
* Migration warning.
*/
const MESSAGE_WARNING = 2;
/**
* Migration notice.
*/
const MESSAGE_NOTICE = 3;
/**
* Migration info.
*/
const MESSAGE_INFORMATIONAL = 4;
/**
* All records have been processed.
*/
const RESULT_COMPLETED = 1;
/**
* The process has stopped itself (e.g., the memory limit is approaching).
*/
const RESULT_INCOMPLETE = 2;
/**
* The process was stopped externally (e.g., via drush migrate-stop).
*/
const RESULT_STOPPED = 3;
/**
* The process had a fatal error.
*/
const RESULT_FAILED = 4;
/**
* Dependencies are unfulfilled - skip the process.
*/
const RESULT_SKIPPED = 5;
/**
* This migration is disabled, skipping.
*/
const RESULT_DISABLED = 6;
/**
* An alias for getPluginId() for backwards compatibility reasons.
*
* @return string
* The plugin_id of the plugin instance.
*
* @see \Drupal\migrate\Plugin\MigrationInterface::getPluginId()
*/
public function id();
/**
* Get the plugin label.
*
* @return string
* The label for this migration.
*/
public function label();
/**
* Returns the initialized source plugin.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface
* The source plugin.
*/
public function getSourcePlugin();
/**
* Returns the process plugins.
*
* @param array $process
* A process configuration array.
*
* @return \Drupal\migrate\Plugin\MigrateProcessInterface[][]
* An associative array. The keys are the destination property names. Values
* are process pipelines. Each pipeline contains an array of plugins.
*/
public function getProcessPlugins(array $process = NULL);
/**
* Returns the initialized destination plugin.
*
* @param bool $stub_being_requested
* TRUE to indicate that this destination will be asked to construct a stub.
*
* @return \Drupal\migrate\Plugin\MigrateDestinationInterface
* The destination plugin.
*/
public function getDestinationPlugin($stub_being_requested = FALSE);
/**
* Returns the initialized id_map plugin.
*
* @return \Drupal\migrate\Plugin\MigrateIdMapInterface
* The ID map.
*/
public function getIdMap();
/**
* The current value of the high water mark.
*
* The high water mark defines a timestamp stating the time the import was last
* run. If the mark is set, only content with a higher timestamp will be
* imported.
*
* @return int
* A Unix timestamp representing the high water mark.
*/
public function getHighWater();
/**
* Save the new high water mark.
*
* @param int $high_water
* The high water timestamp.
*/
public function saveHighWater($high_water);
/**
* Check if all source rows from this migration have been processed.
*
* @return bool
* TRUE if this migration is complete otherwise FALSE.
*/
public function allRowsProcessed();
/**
* Set the current migration status.
*
* @param int $result
* One of the STATUS_* constants.
*/
public function setStatus($status);
/**
* Get the current migration status.
*
* @return int
* The current migration status. Defaults to STATUS_IDLE.
*/
public function getStatus();
/**
* Retrieve a label for the current status.
*
* @return string
* User-friendly string corresponding to a STATUS_ constant.
*/
public function getStatusLabel();
/**
* Get the result to return upon interruption.
*
* @return int
* The current interruption result. Defaults to RESULT_INCOMPLETE.
*/
public function getInterruptionResult();
/**
* Clears the result to return upon interruption.
*/
public function clearInterruptionResult();
/**
* Signal that the migration should be interrupted with the specified result
* code.
*
* @param int $result
* One of the MigrationInterface::RESULT_* constants.
*/
public function interruptMigration($result);
/**
* Get the normalized process pipeline configuration describing the process
* plugins.
*
* The process configuration is always normalized. All shorthand processing
* will be expanded into their full representations.
*
* @see https://www.drupal.org/node/2129651#get-shorthand
*
* @return array
* The normalized configuration describing the process plugins.
*/
public function getProcess();
/**
* Allows you to override the entire process configuration.
*
* @param array $process
* The entire process pipeline configuration describing the process plugins.
*
* @return $this
*/
public function setProcess(array $process);
/**
* Set the process pipeline configuration for an individual destination field.
*
* This method allows you to set the process pipeline configuration for a
* single property within the full process pipeline configuration.
*
* @param string $property
* The property of which to set the process pipeline configuration.
* @param mixed $process_of_property
* The process pipeline configuration to be set for this property.
*
* @return $this
* The migration entity.
*/
public function setProcessOfProperty($property, $process_of_property);
/**
* Merge the process pipeline configuration for a single property.
*
* @param string $property
* The property of which to merge the passed in process pipeline
* configuration.
* @param array $process_of_property
* The process pipeline configuration to be merged with the existing process
* pipeline configuration.
*
* @return $this
* The migration entity.
*
* @see Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity::processLinkField().
*/
public function mergeProcessOfProperty($property, array $process_of_property);
/**
* Get the current system of record of the migration.
*
* @return string
* The current system of record of the migration.
*/
public function getSystemOfRecord();
/**
* Set the system of record for the migration.
*
* @param string $system_of_record
* The system of record of the migration.
*
* @return $this
*/
public function setSystemOfRecord($system_of_record);
/**
* Checks if the migration should track time of last import.
*
* @return bool
* TRUE if the migration is tracking last import time.
*/
public function isTrackLastImported();
/**
* Set if the migration should track time of last import.
*
* @param bool $track_last_imported
* Boolean value to indicate if the migration should track last import time.
*
* @return $this
*/
public function setTrackLastImported($track_last_imported);
/**
* Get the dependencies for this migration.
*
* @return array
* The dependencies for this migrations.
*/
public function getMigrationDependencies();
/**
* Get the destination configuration, with at least a 'plugin' key.
*
* @return array
* The destination configuration.
*/
public function getDestinationConfiguration();
/**
* Get the source configuration, with at least a 'plugin' key.
*
* @return array
* The source configuration.
*/
public function getSourceConfiguration();
/**
* Get information on the property used as the high watermark.
*
* Array of 'name' & (optional) db 'alias' properties used for high watermark.
*
* @see Drupal\migrate\Plugin\migrate\source\SqlBase::initializeIterator()
*
* @return array
* The property used as the high watermark.
*/
public function getHighWaterProperty();
/**
* If true, track time of last import.
*
* @return bool
* Flag to determine desire of tracking time of last import.
*/
public function getTrackLastImported();
/**
* The destination identifiers.
*
* An array of destination identifiers: the keys are the name of the
* properties, the values are dependent on the ID map plugin.
*
* @return array
* Destination identifiers.
*/
public function getDestinationIds();
}

View file

@ -0,0 +1,229 @@
<?php
namespace Drupal\migrate\Plugin;
use Drupal\Component\Graph\Graph;
use Drupal\Component\Plugin\PluginBase;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeDiscoveryDecorator;
use Drupal\Core\Plugin\Discovery\YamlDirectoryDiscovery;
use Drupal\Core\Plugin\Factory\ContainerFactory;
use Drupal\migrate\MigrateBuildDependencyInterface;
/**
* Plugin manager for migration plugins.
*/
class MigrationPluginManager extends DefaultPluginManager implements MigrationPluginManagerInterface, MigrateBuildDependencyInterface {
/**
* Provides default values for migrations.
*
* @var array
*/
protected $defaults = array(
'class' => '\Drupal\migrate\Plugin\Migration',
);
/**
* The interface the plugins should implement.
*
* @var string
*/
protected $pluginInterface = 'Drupal\migrate\Plugin\MigrationInterface';
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Construct a migration plugin manager.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* The cache backend for the definitions.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager) {
$this->factory = new ContainerFactory($this, $this->pluginInterface);
$this->alterInfo('migration_plugins');
$this->setCacheBackend($cache_backend, 'migration_plugins', array('migration_plugins'));
$this->moduleHandler = $module_handler;
}
/**
* {@inheritdoc}
*/
protected function getDiscovery() {
if (!isset($this->discovery)) {
$directories = array_map(function($directory) {
return [$directory . '/migration_templates', $directory . '/migrations'];
}, $this->moduleHandler->getModuleDirectories());
$yaml_discovery = new YamlDirectoryDiscovery($directories, 'migrate');
$this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery);
}
return $this->discovery;
}
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
$instances = $this->createInstances([$plugin_id], $configuration);
return reset($instances);
}
/**
* {@inheritdoc}
*/
public function createInstances($migration_id, array $configuration = array()) {
if (empty($migration_id)) {
$migration_id = array_keys($this->getDefinitions());
}
$factory = $this->getFactory();
$migration_ids = (array) $migration_id;
$plugin_ids = $this->expandPluginIds($migration_ids);
$instances = [];
foreach ($plugin_ids as $plugin_id) {
$instances[$plugin_id] = $factory->createInstance($plugin_id, isset($configuration[$plugin_id]) ? $configuration[$plugin_id] : []);
}
foreach ($instances as $migration) {
$migration->set('migration_dependencies', array_map([$this, 'expandPluginIds'], $migration->getMigrationDependencies()));
}
// Sort the migrations based on their dependencies.
return $this->buildDependencyMigration($instances, []);
}
/**
* Create migrations given a tag.
*
* @param string $tag
* A migration tag we want to filter by.
*
* @return array|\Drupal\migrate\Plugin\MigrationInterface[]
* An array of migration objects with the given tag.
*/
public function createInstancesByTag($tag) {
$migrations = array_filter($this->getDefinitions(), function($migration) use ($tag) {
return !empty($migration['migration_tags']) && in_array($tag, $migration['migration_tags']);
});
return $this->createInstances(array_keys($migrations));
}
/**
* Expand derivative migration dependencies.
*
* We need to expand any derivative migrations. Derivative migrations are
* calculated by migration derivers such as D6NodeDeriver. This allows
* migrations to depend on the base id and then have a dependency on all
* derivative migrations. For example, d6_comment depends on d6_node but after
* we've expanded the dependencies it will depend on d6_node:page,
* d6_node:story and so on, for other derivative migrations.
*
* @return array
* An array of expanded plugin ids.
*/
protected function expandPluginIds(array $migration_ids) {
$plugin_ids = [];
foreach ($migration_ids as $id) {
$plugin_ids += preg_grep('/^' . preg_quote($id, '/') . PluginBase::DERIVATIVE_SEPARATOR . '/', array_keys($this->getDefinitions()));
if ($this->hasDefinition($id)) {
$plugin_ids[] = $id;
}
}
return $plugin_ids;
}
/**
* {@inheritdoc}
*/
public function buildDependencyMigration(array $migrations, array $dynamic_ids) {
// Migration dependencies can be optional or required. If an optional
// dependency does not run, the current migration is still OK to go. Both
// optional and required dependencies (if run at all) must run before the
// current migration.
$dependency_graph = [];
$required_dependency_graph = [];
foreach ($migrations as $migration) {
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$id = $migration->id();
$requirements[$id] = [];
$dependency_graph[$id]['edges'] = [];
$migration_dependencies = $migration->getMigrationDependencies();
if (isset($migration_dependencies['required'])) {
foreach ($migration_dependencies['required'] as $dependency) {
if (!isset($dynamic_ids[$dependency])) {
$this->addDependency($required_dependency_graph, $id, $dependency, $dynamic_ids);
}
$this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids);
}
}
if (isset($migration_dependencies['optional'])) {
foreach ($migration_dependencies['optional'] as $dependency) {
$this->addDependency($dependency_graph, $id, $dependency, $dynamic_ids);
}
}
}
$dependency_graph = (new Graph($dependency_graph))->searchAndSort();
if (!empty($migration_dependencies['optional'])) {
$required_dependency_graph = (new Graph($required_dependency_graph))->searchAndSort();
}
else {
$required_dependency_graph = $dependency_graph;
}
$weights = [];
foreach ($migrations as $migration_id => $migration) {
// Populate a weights array to use with array_multisort() later.
$weights[] = $dependency_graph[$migration_id]['weight'];
if (!empty($required_dependency_graph[$migration_id]['paths'])) {
$migration->set('requirements', $required_dependency_graph[$migration_id]['paths']);
}
}
array_multisort($weights, SORT_DESC, SORT_NUMERIC, $migrations);
return $migrations;
}
/**
* Add one or more dependencies to a graph.
*
* @param array $graph
* The graph so far, passed by reference.
* @param int $id
* The migration ID.
* @param string $dependency
* The dependency string.
* @param array $dynamic_ids
* The dynamic ID mapping.
*/
protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids) {
$dependencies = isset($dynamic_ids[$dependency]) ? $dynamic_ids[$dependency] : array($dependency);
if (!isset($graph[$id]['edges'])) {
$graph[$id]['edges'] = array();
}
$graph[$id]['edges'] += array_combine($dependencies, $dependencies);
}
/**
* {@inheritdoc}
*/
public function createStubMigration(array $definition) {
$id = isset($definition['id']) ? $definition['id'] : uniqid();
return Migration::create(\Drupal::getContainer(), [], $id, $definition);
}
}

View file

@ -0,0 +1,43 @@
<?php
namespace Drupal\migrate\Plugin;
use Drupal\Component\Plugin\PluginManagerInterface;
/**
* Migration plugin manager interface.
*/
interface MigrationPluginManagerInterface extends PluginManagerInterface {
/**
* Create pre-configured instance of plugin derivatives.
*
* @param array $id
* Either the plugin ID or the base plugin ID of the plugins being
* instantiated. Also accepts an array of plugin IDs and an empty array to
* load all plugins.
* @param array $configuration
* An array of configuration relevant to the plugin instances. Keyed by the
* plugin ID.
*
* @return \Drupal\migrate\Plugin\MigrationInterface[]
* Fully configured plugin instances.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If an instance cannot be created, such as if the ID is invalid.
*/
public function createInstances($id, array $configuration = array());
/**
* Creates a stub migration plugin from a definition array.
*
* @param array $definition
* The migration definition. If an 'id' key is set then this will be used as
* the migration ID, if not a random ID will be assigned.
*
* @return \Drupal\migrate\Plugin\Migration
* The stub migration.
*/
public function createStubMigration(array $definition);
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\RequirementsInterface.
*/
namespace Drupal\migrate\Plugin;
/**

View file

@ -1,53 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\builder\BuilderBase.
*/
namespace Drupal\migrate\Plugin\migrate\builder;
use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Plugin\MigrateBuilderInterface;
/**
* Provides abstract base class for builder plugins.
*/
abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface {
/**
* Returns a fully initialized instance of a source plugin.
*
* @param string $plugin_id
* The plugin ID.
* @param array $configuration
* (optional) Additional configuration for the plugin. Defaults to an empty
* array.
*
* @return \Drupal\migrate\Plugin\MigrateSourceInterface|\Drupal\migrate\Plugin\RequirementsInterface
* The fully initialized source plugin.
*/
protected function getSourcePlugin($plugin_id, array $configuration = []) {
$configuration['plugin'] = $plugin_id;
// By default, SqlBase subclasses will try to join on a map table. But in
// this case we're trying to use the source plugin as a detached iterator
// over the source data, so we don't want to join on (or create) the map
// table.
// @see SqlBase::initializeIterator()
$configuration['ignore_map'] = TRUE;
// Source plugins are tightly coupled to migration entities, so we need
// to create a fake migration in order to properly initialize the plugin.
$values = [
'id' => uniqid(),
'source' => $configuration,
// Since this isn't a real migration, we don't want a real destination --
// the 'null' destination is perfect for this.
'destination' => [
'plugin' => 'null',
],
];
return Migration::create($values)->getSourcePlugin();
}
}

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\ComponentEntityDisplayBase.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\Config.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Plugin\DependentPluginInterface;
@ -12,7 +7,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\DependencyTrait;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -55,7 +50,7 @@ class Config extends DestinationBase implements ContainerFactoryPluginInterface,
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration entity.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.

View file

@ -1,14 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\DestinationBase.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\MigrateDestinationInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
@ -43,7 +38,7 @@ abstract class DestinationBase extends PluginBase implements MigrateDestinationI
/**
* The migration.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -56,7 +51,7 @@ abstract class DestinationBase extends PluginBase implements MigrateDestinationI
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {

View file

@ -1,17 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\Entity.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Entity\DependencyTrait;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityBaseFieldOverride.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Row;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityConfigBase.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Utility\NestedArray;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityContentBase.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Entity\ContentEntityInterface;
@ -13,7 +8,7 @@ use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Row;
@ -47,7 +42,7 @@ class EntityContentBase extends Entity {
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration entity.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The storage for this entity type.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityFieldInstance.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityFieldStorageConfig.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityRevision.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Entity\ContentEntityInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityViewMode.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
/**

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\NullDestination.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\PerComponentEntityDisplay.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\PerComponentEntityFormDisplay.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
/**

View file

@ -1,17 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\id_map\Sql.
*/
namespace Drupal\migrate\Plugin\migrate\id_map;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Event\MigrateIdMapMessageEvent;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateMessageInterface;
@ -83,7 +78,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
/**
* The migration being done.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -154,7 +149,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
* The plugin ID for the migration process to do.
* @param mixed $plugin_definition
* The configuration for the plugin.
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration to do.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) {
@ -570,7 +565,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$this->message->display(t('Could not save to map table due to missing destination id values'), 'error');
return;
}
if ($this->migration->get('trackLastImported')) {
if ($this->migration->getTrackLastImported()) {
$fields['last_imported'] = time();
}
$keys = [static::SOURCE_IDS_HASH => $this->getSourceIDsHash($source_id_values)];

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Callback.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Concat.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\MigrateException;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\DedupeBase.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,15 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\DedupeEntity.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\DefaultValue.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Explode.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Extract.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Component\Utility\NestedArray;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Flatten.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Get.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Iterator.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\MachineName.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Component\Transliteration\TransliterationInterface;

View file

@ -1,18 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\MenuLinkContent.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Menu\MenuLinkManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Url;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateProcessInterface;

View file

@ -1,18 +1,14 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Migration.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateSkipProcessException;
use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -34,18 +30,18 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
protected $processPluginManager;
/**
* The entity storage manager.
* The migration plugin manager.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
*/
protected $migrationStorage;
protected $migrationPluginManager;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, MigratePluginManager $process_plugin_manager) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $process_plugin_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migrationStorage = $storage;
$this->migrationPluginManager = $migration_plugin_manager;
$this->migration = $migration;
$this->processPluginManager = $process_plugin_manager;
}
@ -59,7 +55,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
$plugin_id,
$plugin_definition,
$migration,
$container->get('entity.manager')->getStorage('migration'),
$container->get('plugin.manager.migration'),
$container->get('plugin.manager.migrate.process')
);
}
@ -79,10 +75,10 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
}
$this->skipOnEmpty($value);
$self = FALSE;
/** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
$migrations = $this->migrationStorage->loadMultiple($migration_ids);
/** @var \Drupal\migrate\Plugin\MigrationInterface[] $migrations */
$destination_ids = NULL;
$source_id_values = array();
$migrations = $this->migrationPluginManager->createInstances($migration_ids);
foreach ($migrations as $migration_id => $migration) {
if ($migration_id == $this->migration->id()) {
$self = TRUE;
@ -120,7 +116,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
}
$destination_plugin = $migration->getDestinationPlugin(TRUE);
// Only keep the process necessary to produce the destination ID.
$process = $migration->get('process');
$process = $migration->getProcess();
// We already have the source ID values but need to key them for the Row
// constructor.
@ -130,7 +126,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
$values[$source_id] = $source_id_values[$migration->id()][$index];
}
$stub_row = new Row($values + $migration->get('source'), $source_ids, TRUE);
$stub_row = new Row($values + $migration->getSourceConfiguration(), $source_ids, TRUE);
// Do a normal migration with the stub row.
$migrate_executable->processRow($stub_row, $process);
@ -139,7 +135,11 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
$destination_ids = $destination_plugin->import($stub_row);
}
catch (\Exception $e) {
$migrate_executable->saveMessage($e->getMessage());
$migration->getIdMap()->saveMessage($stub_row->getSourceIdValues(), $e->getMessage());
}
if ($destination_ids) {
$migration->getIdMap()->saveIdMapping($stub_row, $destination_ids, MigrateIdMapInterface::STATUS_NEEDS_UPDATE);
}
}
if ($destination_ids) {

View file

@ -1,15 +1,10 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Route.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Core\Path\PathValidatorInterface;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\SkipOnEmpty.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\MigrateSkipProcessException;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\SkipRowIfNotSet.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\StaticMap.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Component\Utility\NestedArray;

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\source\DummyQueryTrait.
*/
namespace Drupal\migrate\Plugin\migrate\source;
/**

View file

@ -1,12 +1,7 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\source\EmbeddedDataSource.
*/
namespace Drupal\migrate\Plugin\migrate\source;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
/**
* Source which takes its data directly from the plugin config.

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\source\EmptySource.
*/
namespace Drupal\migrate\Plugin\migrate\source;
/**

View file

@ -1,14 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\source\SourcePluginBase.
*/
namespace Drupal\migrate\Plugin\migrate\source;
use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
@ -37,7 +32,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
/**
* The entity migration object.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -153,7 +148,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
$this->idMap = $this->migration->getIdMap();
// Pull out the current highwater mark if we have a highwater property.
if ($this->highWaterProperty = $this->migration->get('highWaterProperty')) {
if ($this->highWaterProperty = $this->migration->getHighWaterProperty()) {
$this->originalHighWater = $this->migration->getHighWater();
}
@ -300,7 +295,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
$row_data = $this->getIterator()->current() + $this->configuration;
$this->getIterator()->next();
$row = new Row($row_data, $this->migration->getSourcePlugin()->getIds(), $this->migration->get('destinationIds'));
$row = new Row($row_data, $this->migration->getSourcePlugin()->getIds(), $this->migration->getDestinationIds());
// Populate the source key for this row.
$this->currentSourceIds = $row->getSourceIdValues();

View file

@ -1,16 +1,11 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\source\SqlBase.
*/
namespace Drupal\migrate\Plugin\migrate\source;
use Drupal\Core\Database\Database;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\State\StateInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\migrate\id_map\Sql;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -91,6 +86,9 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
if (isset($this->configuration['database_state_key'])) {
$this->database = $this->setUpDatabase($this->state->get($this->configuration['database_state_key']));
}
elseif (($fallback_state_key = $this->state->get('migrate.fallback_state_key'))) {
$this->database = $this->setUpDatabase($this->state->get($fallback_state_key));
}
else {
$this->database = $this->setUpDatabase($this->configuration);
}
@ -163,7 +161,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
*/
protected function initializeIterator() {
$this->prepareQuery();
$high_water_property = $this->migration->get('highWaterProperty');
$high_water_property = $this->migration->getHighWaterProperty();
// Get the key values, for potential use in joining to the map table.
$keys = array();
@ -205,7 +203,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
$map_key = 'sourceid' . $count;
$this->query->addField($alias, $map_key, "migrate_map_$map_key");
}
if ($n = count($this->migration->get('destinationIds'))) {
if ($n = count($this->migration->getDestinationIds())) {
for ($count = 1; $count <= $n; $count++) {
$map_key = 'destid' . $count++;
$this->query->addField($alias, $map_key, "migrate_map_$map_key");