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,40 +0,0 @@
# Basic data types for Migrate.
migrate_plugin:
type: mapping
mapping:
plugin:
type: string
label: 'Plugin'
migrate_destination:
type: migrate_plugin
label: 'Destination'
mapping:
overwrite_properties:
type: sequence
label: 'Properties to overwrite'
sequence:
type: string
label: 'Property'
migrate_source:
type: migrate_plugin
label: 'Source'
mapping:
constants:
type: ignore
label: 'Constants'
migrate_process:
type: migrate_plugin
label: 'Process'
# Base schema for migrate source plugins that extend
# \Drupal\migrate\Plugin\migrate\source\SqlBase.
migrate_source_sql:
type: migrate_source
mapping:
target:
type: string
label: 'The migration database target'

View file

@ -1,18 +0,0 @@
# Schema for the migrate destination plugins.
migrate.destination.*:
type: migrate_destination
label: 'Default destination'
mapping:
no_stub:
type: boolean
label: 'Whether stubbing is allowed.'
default: false
migrate.destination.config:
type: migrate_destination
label: 'Config'
mapping:
config_name:
type: string
label: 'Configuration name'

View file

@ -1,145 +0,0 @@
# Schema for the migrate process plugins.
migrate.process.*:
type: migrate_process
label: 'Default process'
migrate.process.callback:
type: migrate_process
label: 'Callback process'
mapping:
callback:
type: string
label: 'Callback'
migrate.process.concat:
type: migrate_process
label: 'Concat process'
mapping:
delimiter:
type: string
label: 'Delimiter'
migrate.process.dedupe_entity:
type: migrate_process
label: 'Dedupe Entity process'
mapping:
entity_type:
type: string
label: 'Entity type'
field:
type: string
label: 'Field name'
postfix:
type: string
label: 'Postfix'
start:
type: integer
label: 'Start'
length:
type: integer
label: 'Length'
migrate.process.explode:
type: migrate_process
label: 'Explode process'
mapping:
delimiter:
type: string
label: 'Delimiter'
limit:
type: integer
label: 'Limit'
migrate.process.extract:
type: migrate_process
label: 'Extract process'
mapping:
default:
type: string
label: 'Default value'
migrate.process.flatten:
type: migrate_process
label: 'Flatten process'
migrate.process.get:
type: migrate_process
label: 'Get process'
mapping:
source:
type: string
label: 'Source key'
migrate.process.iterator:
type: migrate_process
label: 'Iterator process'
mapping:
process:
type: ignore
label: 'Process'
key:
type: string
label: 'Key'
migrate.process.machine_name:
type: migrate_process
label: 'Machine name process'
migrate.process.migration:
type: migrate_process
label: 'Migration process'
mapping:
migration:
type: sequence
label: 'Migration'
source:
type: sequence
label: 'Source keys'
source_ids:
type: string
label: 'Source IDs'
stub_id:
type: string
label: 'Stub ID'
migrate.process.route:
type: migrate_process
label: 'Route process'
migrate.process.skip_on_empty:
type: migrate_process
label: 'Skip on Empty'
migrate.process.skip_row_if_not_set:
type: migrate_process
label: 'Skip Row process if not set'
mapping:
index:
type: integer
label: 'Index'
migrate.process.static_map:
type: migrate_process
label: 'Static Map'
mapping:
map:
type: sequence
label: 'Map'
default_value:
type: string
label: 'Default value'
bypass:
type: boolean
label: 'Bypass lookup'
migrate.process.default_value:
type: migrate_process
label: 'Default value'
mapping:
strict:
type: boolean
label: 'Strict type check'
default_value:
type: string
label: 'Default value'

View file

@ -1,46 +0,0 @@
# Schema for the configuration files of the Migrate module.
migrate.migration.*:
type: config_entity
label: 'Migration'
mapping:
id:
type: string
label: 'ID'
migration_tags:
type: sequence
label: 'Migration Tags'
sequence:
type: string
label: 'Tag'
label:
type: label
label: 'Label'
source:
type: migrate.source.[plugin]
label: 'Source'
process:
type: ignore
label: 'Process'
destination:
type: migrate.destination.[plugin]
label: 'Destination'
template:
type: string
label: 'Template'
migration_dependencies:
type: mapping
label: 'Dependencies'
mapping:
required:
type: sequence
label: 'Required dependencies'
sequence:
type: string
label: 'Dependency'
optional:
type: sequence
label: 'Optional dependencies'
sequence:
type: string
label: 'Dependency'

View file

@ -1,34 +0,0 @@
# Schema for the migrate source plugins.
migrate.source.*:
type: migrate_source
label: 'Default source'
migrate.source.empty:
type: migrate_source_sql
label: 'Empty source'
mapping:
provider:
type: string
label: 'Provider'
migrate.source.embedded_data:
type: migrate_source
label: 'Embedded data source'
mapping:
data_rows:
type: sequence
label: 'Data rows'
sequence:
type: ignore
label: 'Data row'
ids:
type: sequence
label: 'Unique key'
sequence:
type: mapping
label: 'Key column'
mapping:
type:
type: string
label: 'Column type'

View file

@ -5,7 +5,7 @@
* Hooks provided by the Migrate module.
*/
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;

View file

@ -5,12 +5,6 @@ services:
- { name: cache.bin }
factory: cache_factory:get
arguments: [migrate]
migrate.template_storage:
class: Drupal\migrate\MigrateTemplateStorage
arguments: ['@module_handler']
migrate.migration_builder:
class: Drupal\migrate\MigrationBuilder
arguments: ['@plugin.manager.migrate.builder']
plugin.manager.migrate.source:
class: Drupal\migrate\Plugin\MigratePluginManager
arguments: [source, '@container.namespaces', '@cache.discovery', '@module_handler', 'Drupal\migrate\Annotation\MigrateSource']
@ -23,6 +17,6 @@ services:
plugin.manager.migrate.id_map:
class: Drupal\migrate\Plugin\MigratePluginManager
arguments: [id_map, '@container.namespaces', '@cache.discovery', '@module_handler']
plugin.manager.migrate.builder:
class: Drupal\migrate\Plugin\MigratePluginManager
arguments: [builder, '@container.namespaces', '@cache.discovery', '@module_handler']
plugin.manager.migration:
class: Drupal\migrate\Plugin\MigrationPluginManager
arguments: ['@module_handler', '@cache.discovery', '@language_manager']

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Annotation\MigrateDestination.
*/
namespace Drupal\migrate\Annotation;
use Drupal\Component\Annotation\Plugin;
@ -48,13 +43,4 @@ class MigrateDestination extends Plugin {
*/
public $requirements_met = TRUE;
/**
* A class to make the plugin derivative aware.
*
* @var string
*
* @see \Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator
*/
public $derivative;
}

View file

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

View file

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

View file

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

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Event\MigrateIdMapMessageEvent.
*/
namespace Drupal\migrate\Event;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
@ -18,7 +13,7 @@ class MigrateIdMapMessageEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -46,7 +41,7 @@ class MigrateIdMapMessageEvent extends Event {
/**
* Constructs a post-save event object.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param array $source_id_values
* Values represent the source ID.
@ -65,7 +60,7 @@ class MigrateIdMapMessageEvent extends Event {
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Entity\MigrationInterface
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration entity involved.
*/
public function getMigration() {

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Event\MigrateImportEvent.
*/
namespace Drupal\migrate\Event;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
@ -18,14 +13,14 @@ class MigrateImportEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Constructs an import event object.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
*/
public function __construct(MigrationInterface $migration) {
@ -35,7 +30,7 @@ class MigrateImportEvent extends Event {
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Entity\MigrationInterface
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration entity involved.
*/
public function getMigration() {

View file

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

View file

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

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Event\MigratePostRowSaveEvent.
*/
namespace Drupal\migrate\Event;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
/**
@ -18,7 +13,7 @@ class MigratePostRowSaveEvent extends MigratePreRowSaveEvent {
/**
* Constructs a post-save event object.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param \Drupal\migrate\Row $row
* Row object.

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Event\MigratePreRowSaveEvent.
*/
namespace Drupal\migrate\Event;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Row;
use Symfony\Component\EventDispatcher\Event;
@ -26,14 +21,14 @@ class MigratePreRowSaveEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Constructs a pre-save event object.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
*/
public function __construct(MigrationInterface $migration, Row $row) {
@ -44,7 +39,7 @@ class MigratePreRowSaveEvent extends Event {
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Entity\MigrationInterface
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration entity being imported.
*/
public function getMigration() {

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Event\MigrateRollbackEvent.
*/
namespace Drupal\migrate\Event;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
@ -18,14 +13,14 @@ class MigrateRollbackEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Constructs an rollback event object.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
*/
public function __construct(MigrationInterface $migration) {
@ -35,7 +30,7 @@ class MigrateRollbackEvent extends Event {
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Entity\MigrationInterface
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration entity involved.
*/
public function getMigration() {

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Event\MigrateRowDeleteEvent.
*/
namespace Drupal\migrate\Event;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\Event;
/**
@ -18,7 +13,7 @@ class MigrateRowDeleteEvent extends Event {
/**
* Migration entity.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -32,7 +27,7 @@ class MigrateRowDeleteEvent extends Event {
/**
* Constructs a row deletion event object.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* Migration entity.
* @param array $destination_id_values
* Values represent the destination ID.
@ -45,7 +40,7 @@ class MigrateRowDeleteEvent extends Event {
/**
* Gets the migration entity.
*
* @return \Drupal\migrate\Entity\MigrationInterface
* @return \Drupal\migrate\Plugin\MigrationInterface
* The migration being rolled back.
*/
public function getMigration() {

View file

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

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateBuildDependencyInterface.
*/
namespace Drupal\migrate;
@ -12,7 +8,7 @@ interface MigrateBuildDependencyInterface {
/**
* Builds a dependency tree for the migrations and set their order.
*
* @param \Drupal\migrate\Entity\MigrationInterface[] $migrations
* @param \Drupal\migrate\Plugin\MigrationInterface[] $migrations
* Array of loaded migrations with their declared dependencies.
* @param array $dynamic_ids
* Keys are dynamic ids (for example node:*) values are a list of loaded

View file

@ -1,14 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateException.
*/
namespace Drupal\migrate;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
/**
* Defines the migrate exception class.

View file

@ -1,15 +1,9 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateExecutable.
*/
namespace Drupal\migrate;
use Drupal\Core\Utility\Error;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\Event\MigrateImportEvent;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
@ -18,6 +12,7 @@ use Drupal\migrate\Event\MigrateRollbackEvent;
use Drupal\migrate\Event\MigrateRowDeleteEvent;
use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
@ -29,7 +24,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
/**
* The configuration of the migration to do.
*
* @var \Drupal\migrate\Entity\Migration
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -102,7 +97,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
/**
* Constructs a MigrateExecutable and verifies and sets the memory limit.
*
* @param \Drupal\migrate\Entity\MigrationInterface $migration
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration to run.
* @param \Drupal\migrate\MigrateMessageInterface $message
* The message to record.
@ -261,7 +256,7 @@ class MigrateExecutable implements MigrateExecutableInterface {
$this->handleException($e);
}
}
if ($high_water_property = $this->migration->get('highWaterProperty')) {
if ($high_water_property = $this->migration->getHighWaterProperty()) {
$this->migration->saveHighWater($row->getSourceProperty($high_water_property['name']));
}

View file

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

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateMessage.
*/
namespace Drupal\migrate;
use Drupal\Core\Logger\RfcLogLevel;

View file

@ -1,8 +1,4 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateMessageInterface.
*/
namespace Drupal\migrate;

View file

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

View file

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

View file

@ -1,87 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateTemplateStorage.
*/
namespace Drupal\migrate;
use Drupal\Component\Serialization\Yaml;
use Drupal\Core\Extension\ModuleHandlerInterface;
/**
* Storage to access migration template configuration in enabled extensions.
*/
class MigrateTemplateStorage implements MigrateTemplateStorageInterface {
/**
* Extension sub-directory containing default configuration for migrations.
*/
const MIGRATION_TEMPLATE_DIRECTORY = 'migration_templates';
/**
* Template subdirectory.
*
* @var string
*/
protected $directory;
/**
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*/
public function __construct(ModuleHandlerInterface $module_handler, $directory = self::MIGRATION_TEMPLATE_DIRECTORY) {
$this->moduleHandler = $module_handler;
$this->directory = $directory;
}
/**
* {@inheritdoc}
*/
public function findTemplatesByTag($tag) {
$templates = $this->getAllTemplates();
$matched_templates = [];
foreach ($templates as $template_name => $template) {
if (!empty($template['migration_tags'])) {
if (in_array($tag, $template['migration_tags'])) {
$matched_templates[$template_name] = $template;
}
}
}
return $matched_templates;
}
/**
* {@inheritdoc}
*/
public function getTemplateByName($name) {
$templates = $this->getAllTemplates();
return isset($templates[$name]) ? $templates[$name] : NULL;
}
/**
* {@inheritdoc}
*/
public function getAllTemplates() {
$templates = [];
foreach ($this->moduleHandler->getModuleDirectories() as $directory) {
$full_directory = $directory . '/' . $this->directory;
if (file_exists($full_directory)) {
$files = scandir($full_directory);
foreach ($files as $file) {
if ($file[0] !== '.' && preg_match('/\.yml$/', $file)) {
$templates[basename($file, '.yml')] = Yaml::decode(file_get_contents("$full_directory/$file"));
}
}
}
}
return $templates;
}
}

View file

@ -1,45 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrateTemplateStorageInterface.
*/
namespace Drupal\migrate;
/**
* The MigrateTemplateStorageInterface interface.
*/
interface MigrateTemplateStorageInterface {
/**
* Find all migration templates with the specified tag.
*
* @param $tag
* The tag to match.
*
* @return array
* Any templates (parsed YAML config) that matched, keyed by the ID.
*/
public function findTemplatesByTag($tag);
/**
* Retrieve a template given a specific name.
*
* @param string $name
* A migration template name.
*
* @return NULL|array
* A parsed migration template, or NULL if it doesn't exist.
*/
public function getTemplateByName($name);
/**
* Retrieves all migration templates belonging to enabled extensions.
*
* @return array
* Array of parsed templates, keyed by the fully-qualified id.
*/
public function getAllTemplates();
}

View file

@ -1,62 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrationBuilder.
*/
namespace Drupal\migrate;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Plugin\MigratePluginManager;
/**
* Builds migration entities from migration templates.
*/
class MigrationBuilder implements MigrationBuilderInterface {
/**
* The builder plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $builderManager;
/**
* Constructs a MigrationBuilder.
*
* @param \Drupal\migrate\Plugin\MigratePluginManager $builder_manager
* The builder plugin manager.
*/
public function __construct(MigratePluginManager $builder_manager) {
$this->builderManager = $builder_manager;
}
/**
* {@inheritdoc}
*/
public function createMigrations(array $templates) {
/** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
$migrations = [];
foreach ($templates as $template_id => $template) {
if (isset($template['builder'])) {
$variants = $this->builderManager
->createInstance($template['builder']['plugin'], $template['builder'])
->buildMigrations($template);
}
else {
$variants = array(Migration::create($template));
}
/** @var \Drupal\migrate\Entity\MigrationInterface[] $variants */
foreach ($variants as $variant) {
$variant->set('template', $template_id);
}
$migrations = array_merge($migrations, $variants);
}
return $migrations;
}
}

View file

@ -1,27 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrationBuilderInterface.
*/
namespace Drupal\migrate;
/**
* The migration builder interface.
*/
interface MigrationBuilderInterface {
/**
* Builds migration entities from templates.
*
* @param array $templates
* The parsed templates (each of which is an array parsed from YAML), keyed
* by ID.
*
* @return \Drupal\migrate\Entity\MigrationInterface[]
* The migration entities derived from the templates.
*/
public function createMigrations(array $templates);
}

View file

@ -1,10 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\MigrationStorage.
*/
namespace Drupal\migrate;
use Drupal\Component\Graph\Graph;
@ -67,7 +62,7 @@ class MigrationStorage extends ConfigEntityStorage implements MigrateBuildDepend
if ($ids) {
$ids = $this->getVariantIds($ids);
}
/** @var \Drupal\migrate\Entity\MigrationInterface[] $migrations */
/** @var \Drupal\migrate\Plugin\MigrationInterface[] $migrations */
$migrations = parent::loadMultiple($ids);
foreach ($migrations as $migration) {
@ -126,7 +121,7 @@ class MigrationStorage extends ConfigEntityStorage implements MigrateBuildDepend
$requirement_graph = array();
$different = FALSE;
foreach ($migrations as $migration) {
/** @var \Drupal\migrate\Entity\MigrationInterface $migration */
/** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
$id = $migration->id();
$requirements[$id] = array();
$dependency_graph[$id]['edges'] = array();

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

@ -1,40 +1,23 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Entity\Migration.
*/
namespace Drupal\migrate\Plugin;
namespace Drupal\migrate\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
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\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\RequirementsInterface;
use Drupal\Component\Utility\NestedArray;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines the Migration entity.
* Defines the Migration plugin.
*
* The migration entity stores the information about a single migration, like
* the source, process and destination plugins.
*
* @ConfigEntityType(
* id = "migration",
* label = @Translation("Migration"),
* handlers = {
* "storage" = "Drupal\migrate\MigrationStorage"
* },
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "weight" = "weight"
* }
* )
* 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 ConfigEntityBase implements MigrationInterface, RequirementsInterface {
class Migration extends PluginBase implements MigrationInterface, RequirementsInterface, ContainerFactoryPluginInterface {
/**
* The migration ID (machine name).
@ -143,7 +126,9 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
protected $destinationIds = [];
/**
* Information on the high water mark.
* Information on the property used as the high watermark.
*
* Array of 'name' & (optional) db 'alias' properties used for high watermark.
*
* @var array
*/
@ -225,18 +210,39 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
protected $dependencies = [];
/**
* The ID of the template from which this migration was derived, if any.
* The migration plugin manager for loading other migration plugins.
*
* @var string|NULL
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
*/
protected $template;
protected $migrationPluginManager;
/**
* The entity manager.
* The source plugin manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $entityManager;
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.
@ -251,12 +257,101 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
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 = \Drupal::service('plugin.manager.migrate.source')->createInstance($this->source['plugin'], $this->source, $this);
$this->sourcePlugin = $this->sourcePluginManager->createInstance($this->source['plugin'], $this->source, $this);
}
return $this->sourcePlugin;
}
@ -266,7 +361,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
*/
public function getProcessPlugins(array $process = NULL) {
if (!isset($process)) {
$process = $this->process;
$process = $this->getProcess();
}
$index = serialize($process);
if (!isset($this->processPlugins[$index])) {
@ -275,11 +370,11 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
$this->processPlugins[$index][$property] = array();
foreach ($configurations as $configuration) {
if (isset($configuration['source'])) {
$this->processPlugins[$index][$property][] = \Drupal::service('plugin.manager.migrate.process')->createInstance('get', $configuration, $this);
$this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance('get', $configuration, $this);
}
// Get is already handled.
if ($configuration['plugin'] != 'get') {
$this->processPlugins[$index][$property][] = \Drupal::service('plugin.manager.migrate.process')->createInstance($configuration['plugin'], $configuration, $this);
$this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance($configuration['plugin'], $configuration, $this);
}
if (!$this->processPlugins[$index][$property]) {
throw new MigrateException("Invalid process configuration for $property");
@ -324,7 +419,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
throw new MigrateSkipRowException;
}
if (!isset($this->destinationPlugin)) {
$this->destinationPlugin = \Drupal::service('plugin.manager.migrate.destination')->createInstance($this->destination['plugin'], $this->destination, $this);
$this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
}
return $this->destinationPlugin;
}
@ -336,7 +431,7 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
if (!isset($this->idMapPlugin)) {
$configuration = $this->idMap;
$plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql';
$this->idMapPlugin = \Drupal::service('plugin.manager.migrate.id_map')->createInstance($plugin, $configuration, $this);
$this->idMapPlugin = $this->idMapPluginManager->createInstance($plugin, $configuration, $this);
}
return $this->idMapPlugin;
}
@ -381,8 +476,12 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
$this->getDestinationPlugin()->checkRequirements();
}
/** @var \Drupal\migrate\Entity\MigrationInterface[] $required_migrations */
$required_migrations = $this->getEntityManager()->getStorage('migration')->loadMultiple($this->requirements);
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.
@ -397,16 +496,13 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
}
/**
* Get the entity manager.
* Gets the migration plugin manager.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager.
* @return \Drupal\migrate\Plugin\MigratePluginManager
* The plugin manager.
*/
protected function getEntityManager() {
if (!isset($this->entityManager)) {
$this->entityManager = \Drupal::entityManager();
}
return $this->entityManager;
protected function getMigrationPluginManager() {
return $this->migrationPluginManager;
}
/**
@ -487,7 +583,8 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
// Invalidate the destination plugin.
unset($this->destinationPlugin);
}
return parent::set($property_name, $value);
$this->{$property_name} = $value;
return $this;
}
@ -571,28 +668,48 @@ class Migration extends ConfigEntityBase implements MigrationInterface, Requirem
/**
* {@inheritdoc}
*/
public function trustData() {
// Migrations cannot be trusted since they are often written by hand and not
// through a UI.
$this->trustedData = FALSE;
return $this;
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 calculateDependencies() {
parent::calculateDependencies();
$this->calculatePluginDependencies($this->getSourcePlugin());
$this->calculatePluginDependencies($this->getDestinationPlugin());
public function getDestinationConfiguration() {
return $this->destination;
}
// Add hard dependencies on required migrations.
$dependencies = $this->getEntityManager()->getStorage($this->entityTypeId)
->getVariantIds($this->getMigrationDependencies()['required']);
foreach ($dependencies as $dependency) {
$this->addDependency('config', $this->getEntityType()->getConfigPrefix() . '.' . $dependency);
}
/**
* {@inheritdoc}
*/
public function getSourceConfiguration() {
return $this->source;
}
return $this;
/**
* {@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

@ -1,18 +1,14 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Entity\MigrationInterface.
*/
namespace Drupal\migrate\Plugin;
namespace Drupal\migrate\Entity;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
/**
* Interface for migrations.
*/
interface MigrationInterface extends ConfigEntityInterface {
interface MigrationInterface extends PluginInspectionInterface, DerivativeInspectionInterface {
/**
* A constant used for systemOfRecord.
@ -99,6 +95,24 @@ interface MigrationInterface extends ConfigEntityInterface {
*/
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.
*
@ -123,7 +137,7 @@ interface MigrationInterface extends ConfigEntityInterface {
* Returns the initialized destination plugin.
*
* @param bool $stub_being_requested
* TRUE to indicate that this destination will be asked to construct a stub.
* TRUE to indicate that this destination will be asked to construct a stub.
*
* @return \Drupal\migrate\Plugin\MigrateDestinationInterface
* The destination plugin.
@ -257,10 +271,10 @@ interface MigrationInterface extends ConfigEntityInterface {
*
* @param string $property
* The property of which to merge the passed in process pipeline
* configuration.
* configuration.
* @param array $process_of_property
* The process pipeline configuration to be merged with the existing process
* pipeline configuration.
* pipeline configuration.
*
* @return $this
* The migration entity.
@ -313,4 +327,51 @@ interface MigrationInterface extends ConfigEntityInterface {
*/
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");

View file

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

View file

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

View file

@ -1,78 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\TemplateTest.
*/
namespace Drupal\migrate\Tests;
/**
* Tests the migration template functionality.
*
* @group migrate
*/
class TemplateTest extends MigrateTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('template_test');
/**
* Tests different connection types.
*/
public function testTemplates() {
$migration_templates = \Drupal::service('migrate.template_storage')->findTemplatesByTag("Template Test");
$expected_url = [
'id' => 'url_template',
'label' => 'Template test - url',
'migration_tags' => ['Template Test'],
'source' => ['plugin' => 'empty'],
'process' => ['src' => 'foobar'],
'destination' => ['plugin' => 'url_alias'],
];
$expected_node = [
'id' => 'node_template',
'label' => 'Template test - node',
'migration_tags' => ['Template Test'],
'source' => ['plugin' => 'empty'],
'process' => ['src' => 'barfoo'],
'destination' => ['plugin' => 'entity:node'],
];
$this->assertIdentical($migration_templates['migrate.migration.url_template'], $expected_url);
$this->assertIdentical($migration_templates['migrate.migration.node_template'], $expected_node);
$this->assertFalse(isset($migration_templates['migrate.migration.other_template']));
}
/**
* Tests retrieving a template by name.
*/
public function testGetTemplateByName() {
/** @var \Drupal\migrate\MigrateTemplateStorageInterface $template_storage */
$template_storage = \Drupal::service('migrate.template_storage');
$expected_url = [
'id' => 'url_template',
'label' => 'Template test - url',
'migration_tags' => ['Template Test'],
'source' => ['plugin' => 'empty'],
'process' => ['src' => 'foobar'],
'destination' => ['plugin' => 'url_alias'],
];
$expected_node = [
'id' => 'node_template',
'label' => 'Template test - node',
'migration_tags' => ['Template Test'],
'source' => ['plugin' => 'empty'],
'process' => ['src' => 'barfoo'],
'destination' => ['plugin' => 'entity:node'],
];
$this->assertIdentical($template_storage->getTemplateByName('migrate.migration.url_template'), $expected_url);
$this->assertIdentical($template_storage->getTemplateByName('migrate.migration.node_template'), $expected_node);
$this->assertNull($template_storage->getTemplateByName('migrate.migration.dne'));
}
}

View file

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

View file

@ -6,7 +6,7 @@
* handling.
*/
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateSourceInterface;
use Drupal\migrate\Row;

View file

@ -1,5 +1,5 @@
id: url_template
label: Template test - url
label: Template test - URL
migration_tags:
- Template Test
source:

View file

@ -1,76 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\Tests\migrate\Kernel\Entity\MigrationTest.
*/
namespace Drupal\Tests\migrate\Kernel\Entity;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\Entity\Migration;
/**
* Tests the Migration entity.
*
* @coversDefaultClass \Drupal\migrate\Entity\Migration
* @group migrate
*/
class MigrationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate'];
/**
* @covers ::calculateDependencies
*/
public function testCalculateDependencies() {
$fixture_migrations = [
'd6_node__article' => 'd6_node',
'd6_node__page' => 'd6_node',
'd6_variables' => 'd6_variables',
];
foreach ($fixture_migrations as $id => $template) {
$values = [
'id' => $id,
'template' => $template,
'source' => [
'plugin' => 'empty',
],
'destination' => [
'plugin' => 'null',
],
'migration_tags' => []
];
Migration::create($values)->save();
}
$values = [
'migration_dependencies' => [
'required' => [
'd6_node:*',
'd6_variables'
]
],
'source' => [
'plugin' => 'empty',
],
'destination' => [
'plugin' => 'null',
],
];
$migration = new Migration($values, 'migration');
$expected = [
'migrate.migration.d6_node__article',
'migrate.migration.d6_node__page',
'migrate.migration.d6_variables'
];
$migration->calculateDependencies();
$this->assertEquals($expected, $migration->getDependencies()['config']);
}
}

View file

@ -1,13 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateDumpAlterInterface.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\simpletest\TestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Allows tests to alter dumps after they have loaded.
@ -19,9 +14,9 @@ interface MigrateDumpAlterInterface {
/**
* Allows tests to alter dumps after they have loaded.
*
* @param \Drupal\simpletest\TestBase $test
* @param \Drupal\KernelTests\KernelTestBase $test
* The test that is being run.
*/
public static function migrateDumpAlter(TestBase $test);
public static function migrateDumpAlter(KernelTestBase $test);
}

View file

@ -1,15 +1,8 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateEmbeddedDataTest.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Row;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the EmbeddedDataSource plugin.
@ -34,8 +27,7 @@ class MigrateEmbeddedDataTest extends KernelTestBase {
['key' => '2', 'field1' => 'f1value2', 'field2' => 'f2value2'],
];
$ids = ['key' => ['type' => 'integer']];
$config = [
'id' => 'sample_data',
$definition = [
'migration_tags' => ['Embedded data test'],
'source' => [
'plugin' => 'embedded_data',
@ -46,12 +38,12 @@ class MigrateEmbeddedDataTest extends KernelTestBase {
'destination' => ['plugin' => 'null'],
];
$migration = Migration::create($config);
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$source = $migration->getSourcePlugin();
// Validate the plugin returns the source data that was provided.
$results = [];
/** @var Row $row */
/** @var \Drupal\migrate\Row $row */
foreach ($source as $row) {
$data_row = $row->getSource();
// The "data" row returned by getSource() also includes all source

View file

@ -1,23 +1,16 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateEventsTest.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Event\MigrateImportEvent;
use Drupal\migrate\Event\MigrateMapDeleteEvent;
use Drupal\migrate\Event\MigrateMapSaveEvent;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Drupal\migrate\Event\MigratePreRowSaveEvent;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\MigrateExecutable;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests events fired on migrations.
@ -66,8 +59,7 @@ class MigrateEventsTest extends KernelTestBase {
public function testMigrateEvents() {
// Run a simple little migration, which should trigger one of each event
// other than map_delete.
$config = [
'id' => 'sample_data',
$definition = [
'migration_tags' => ['Event test'],
'source' => [
'plugin' => 'embedded_data',
@ -82,9 +74,8 @@ class MigrateEventsTest extends KernelTestBase {
'destination' => ['plugin' => 'dummy'],
];
$migration = Migration::create($config);
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
/** @var MigrationInterface $migration */
$executable = new MigrateExecutable($migration, new MigrateMessage());
// As the import runs, events will be dispatched, recording the received
// information in state.

View file

@ -1,19 +1,13 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateInterruptionTest.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\MigrateExecutable;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests interruptions triggered during migrations.
@ -44,8 +38,7 @@ class MigrateInterruptionTest extends KernelTestBase {
public function testMigrateEvents() {
// Run a simple little migration, which should trigger one of each event
// other than map_delete.
$config = [
'id' => 'sample_data',
$definition = [
'migration_tags' => ['Interruption test'],
'source' => [
'plugin' => 'embedded_data',
@ -61,9 +54,8 @@ class MigrateInterruptionTest extends KernelTestBase {
'destination' => ['plugin' => 'dummy'],
];
$migration = Migration::create($config);
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
/** @var MigrationInterface $migration */
$executable = new MigrateExecutable($migration, new MigrateMessage());
// When the import runs, the first row imported will trigger an
// interruption.

View file

@ -1,19 +1,13 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateMessageTest.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\Event\MigrateIdMapMessageEvent;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessageInterface;
use Drupal\simpletest\KernelTestBase;
/**
* Tests whether idmap messages are sent to message interface when requested.
@ -32,7 +26,7 @@ class MigrateMessageTest extends KernelTestBase implements MigrateMessageInterfa
/**
* Migration to run.
*
* @var \Drupal\migrate\Entity\MigrationInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
@ -53,8 +47,7 @@ class MigrateMessageTest extends KernelTestBase implements MigrateMessageInterfa
// A simple migration, which will generate a message to the ID map because
// the concat plugin throws an exception if its source is not an array.
$config = [
'id' => 'sample_data',
$definition = [
'migration_tags' => ['Message test'],
'source' => [
'plugin' => 'embedded_data',
@ -77,7 +70,7 @@ class MigrateMessageTest extends KernelTestBase implements MigrateMessageInterfa
],
];
$this->migration = Migration::create($config);
$this->migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
}
/**

View file

@ -1,13 +1,7 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateRollbackTest.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Row;
@ -49,7 +43,7 @@ class MigrateRollbackTest extends MigrateTestBase {
['id' => '2', 'name' => 'tags', 'weight' => '1'],
];
$ids = ['id' => ['type' => 'integer']];
$config = [
$definition = [
'id' => 'vocabularies',
'migration_tags' => ['Import and rollback test'],
'source' => [
@ -65,7 +59,7 @@ class MigrateRollbackTest extends MigrateTestBase {
'destination' => ['plugin' => 'entity:taxonomy_vocabulary'],
];
$vocabulary_migration = Migration::create($config);
$vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$vocabulary_id_map = $vocabulary_migration->getIdMap();
$this->assertTrue($vocabulary_migration->getDestinationPlugin()->supportsRollback());
@ -89,7 +83,7 @@ class MigrateRollbackTest extends MigrateTestBase {
['id' => '3', 'vocab' => '2', 'name' => 'Beethoven'],
];
$ids = ['id' => ['type' => 'integer']];
$config = [
$definition = [
'id' => 'terms',
'migration_tags' => ['Import and rollback test'],
'source' => [
@ -106,7 +100,7 @@ class MigrateRollbackTest extends MigrateTestBase {
'migration_dependencies' => ['required' => ['vocabularies']],
];
$term_migration = Migration::create($config);
$term_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$term_id_map = $term_migration->getIdMap();
$this->assertTrue($term_migration->getDestinationPlugin()->supportsRollback());
@ -160,7 +154,7 @@ class MigrateRollbackTest extends MigrateTestBase {
['id' => 1, 'override_selector' => '0', 'terms_per_page_admin' => '10'],
];
$ids = ['id' => ['type' => 'integer']];
$config = [
$definition = [
'id' => 'taxonomy_settings',
'migration_tags' => ['Import and rollback test'],
'source' => [
@ -179,7 +173,7 @@ class MigrateRollbackTest extends MigrateTestBase {
'migration_dependencies' => ['required' => ['vocabularies']],
];
$settings_migration = Migration::create($config);
$settings_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$this->assertFalse($settings_migration->getDestinationPlugin()->supportsRollback());
}

View file

@ -1,18 +1,12 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Tests\MigrateSkipRowTest.
*/
namespace Drupal\Tests\migrate\Kernel;
namespace Drupal\migrate\Tests;
use Drupal\migrate\Entity\Migration;
use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\simpletest\KernelTestBase;
/**
* Tests row skips triggered during hook_migrate_prepare_row().
@ -34,8 +28,7 @@ class MigrateSkipRowTest extends KernelTestBase {
public function testPrepareRowSkip() {
// Run a simple little migration with two data rows which should be skipped
// in different ways.
$config = [
'id' => 'sample_data',
$definition = [
'migration_tags' => ['prepare_row test'],
'source' => [
'plugin' => 'embedded_data',
@ -55,7 +48,7 @@ class MigrateSkipRowTest extends KernelTestBase {
'load' => ['plugin' => 'null'],
];
$migration = Migration::create($config);
$migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage());
$result = $executable->import();

Some files were not shown because too many files have changed in this diff Show more