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

This commit is contained in:
Pantheon Automation 2016-01-06 16:31:26 -08:00 committed by Greg Anderson
parent 1a0e9d9fac
commit a6b049dd05
538 changed files with 5247 additions and 1594 deletions

View file

@ -11,8 +11,8 @@ 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
* 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 {

View file

@ -12,6 +12,8 @@ use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
/**
* Defines an interface for Migration Destination classes.
*
* Destinations are responsible for persisting source data into the destination
* Drupal.
*
@ -25,7 +27,7 @@ use Drupal\migrate\Row;
interface MigrateDestinationInterface extends PluginInspectionInterface {
/**
* Get the destination ids.
* Get the destination IDs.
*
* To support MigrateIdMap maps, derived destination classes should return
* schema field definition(s) corresponding to the primary key of the
@ -33,7 +35,7 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
* key fields of the map table for a migration using this destination.
*
* @return array
* An array of ids.
* An array of IDs.
*/
public function getIds();
@ -43,11 +45,11 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
* Derived classes must implement fields(), returning a list of available
* destination fields.
*
* @todo Review the cases where we need the Migration parameter,
* can we avoid that?
* @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
* (optional) the migration containing this destination.
* (optional) The migration containing this destination. Defaults to NULL.
*
* @return array
* - Keys: machine names of the fields
@ -64,10 +66,10 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
* @param \Drupal\migrate\Row $row
* The row object.
* @param array $old_destination_id_values
* The old destination ids.
* (optional) The old destination IDs. Defaults to an empty array.
*
* @return mixed
* The entity id or an indication of success.
* The entity ID or an indication of success.
*/
public function import(Row $row, array $old_destination_id_values = array());
@ -95,4 +97,5 @@ interface MigrateDestinationInterface extends PluginInspectionInterface {
* item should be handled on rollback.
*/
public function rollbackAction();
}

View file

@ -5,7 +5,6 @@
* Contains \Drupal\migrate\Plugin\MigrateDestinationPluginManager.
*/
namespace Drupal\migrate\Plugin;
use Drupal\Core\Cache\CacheBackendInterface;
@ -37,7 +36,7 @@ class MigrateDestinationPluginManager extends MigratePluginManager {
*
* @param string $type
* The type of the plugin: row, source, process, destination, entity_field,
* id_map.
* id_map.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
@ -48,7 +47,8 @@ class MigrateDestinationPluginManager extends MigratePluginManager {
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param string $annotation
* The annotation class name.
* (optional) The annotation class name. Defaults to
* 'Drupal\migrate\Annotation\MigrateDestination'.
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager, $annotation = 'Drupal\migrate\Annotation\MigrateDestination') {
parent::__construct($type, $namespaces, $cache_backend, $module_handler, $annotation);

View file

@ -37,8 +37,8 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
/**
* Saves a mapping from the source identifiers to the destination identifiers.
*
* Called upon import of one row, we record a mapping from the source ID
* to the destination ID. Also may be called, setting the third parameter to
* Called upon import of one row, we record a mapping from the source ID to
* the destination ID. Also may be called, setting the third parameter to
* NEEDS_UPDATE, to signal an existing record should be re-migrated.
*
* @param \Drupal\migrate\Row $row
@ -47,9 +47,11 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
* @param array $destination_id_values
* An array of destination identifier values.
* @param int $status
* Status of the source row in the map.
* (optional) Status of the source row in the map. Defaults to
* self::STATUS_IMPORTED.
* @param int $rollback_action
* How to handle the destination object on rollback.
* (optional) How to handle the destination object on rollback. Defaults to
* self::ROLLBACK_DELETE.
*/
public function saveIdMapping(Row $row, array $destination_id_values, $status = self::STATUS_IMPORTED, $rollback_action = self::ROLLBACK_DELETE);
@ -61,7 +63,8 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
* @param string $message
* The message to record.
* @param int $level
* Optional message severity (defaults to MESSAGE_ERROR).
* (optional) The message severity. Defaults to
* MigrationInterface::MESSAGE_ERROR.
*/
public function saveMessage(array $source_id_values, $message, $level = MigrationInterface::MESSAGE_ERROR);
@ -69,10 +72,11 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
* Retrieves an iterator over messages relate to source records.
*
* @param array $source_id_values
* (optional) The source identifier keyed values of the record, e.g. ['nid' => 5].
* If empty, all messages are retrieved.
* (optional) The source identifier keyed values of the record, e.g.
* ['nid' => 5]. If empty (the default), all messages are retrieved.
* @param int $level
* (optional) Message severity. If NULL, retrieve messages of all severities.
* (optional) Message severity. If NULL (the default), retrieve messages of
* all severities.
*
* @return \Iterator
* Retrieves an iterator over the message rows.
@ -136,7 +140,7 @@ interface MigrateIdMapInterface extends \Iterator, PluginInspectionInterface {
* @param array $source_id_values
* The source identifier keyed values of the record, e.g. ['nid' => 5].
* @param bool $messages_only
* TRUE to only delete the migrate messages.
* (optional) TRUE to only delete the migrate messages. Defaults to FALSE.
*/
public function delete(array $source_id_values, $messages_only = FALSE);

View file

@ -34,7 +34,7 @@ class MigratePluginManager extends DefaultPluginManager {
*
* @param string $type
* The type of the plugin: row, source, process, destination, entity_field,
* id_map.
* id_map.
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
@ -43,7 +43,8 @@ class MigratePluginManager extends DefaultPluginManager {
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
* @param string $annotation
* The annotation class name.
* (optional) The annotation class name. Defaults to
* 'Drupal\Component\Annotation\PluginID'.
*/
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, $annotation = 'Drupal\Component\Annotation\PluginID') {
$plugin_interface = isset($plugin_interface_map[$type]) ? $plugin_interface_map[$type] : NULL;

View file

@ -37,12 +37,12 @@ interface MigrateProcessInterface extends PluginInspectionInterface {
* @param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
* The migration in which this process is being executed.
* @param \Drupal\migrate\Row $row
* The row from the source to process. Normally, just transforming the
* value is adequate but very rarely you might need to change two columns
* at the same time or something like that.
* The row from the source to process. Normally, just transforming the value
* is adequate but very rarely you might need to change two columns at the
* same time or something like that.
* @param string $destination_property
* The destination property currently worked on. This is only used
* together with the $row above.
* The destination property currently worked on. This is only used together
* with the $row above.
*
* @return string|array
* The newly transformed value.

View file

@ -31,7 +31,7 @@ interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspection
public function fields();
/**
* Add additional data to the row.
* Adds additional data to the row.
*
* @param \Drupal\Migrate\Row $row
* The row object.
@ -41,13 +41,17 @@ interface MigrateSourceInterface extends \Countable, \Iterator, PluginInspection
*/
public function prepareRow(Row $row);
/**
* Allows class to decide how it will react when it is treated like a string.
*/
public function __toString();
/**
* Defines the source fields uniquely identifying a source row. None of these
* fields should contain a NULL value - if necessary, use prepareRow() or
* hook_migrate_prepare_row() to rewrite NULL values to appropriate empty
* values (such as '' or 0).
* Defines the source fields uniquely identifying a source row.
*
* None of these fields should contain a NULL value. If necessary, use
* prepareRow() or hook_migrate_prepare_row() to rewrite NULL values to
* appropriate empty values (such as '' or 0).
*
* @return array
* Array keyed by source field name, with values being a schema array

View file

@ -12,7 +12,7 @@ use Drupal\migrate\Entity\Migration;
use Drupal\migrate\Plugin\MigrateBuilderInterface;
/**
* Base class for builder plugins.
* Provides abstract base class for builder plugins.
*/
abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface {
@ -22,7 +22,8 @@ abstract class BuilderBase extends PluginBase implements MigrateBuilderInterface
* @param string $plugin_id
* The plugin ID.
* @param array $configuration
* (optional) Additional configuration for the plugin.
* (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.

View file

@ -10,6 +10,9 @@ namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
/**
* Defines the base abstract class for component entity display.
*/
abstract class ComponentEntityDisplayBase extends DestinationBase {
const MODE_NAME = '';
@ -54,7 +57,7 @@ abstract class ComponentEntityDisplayBase extends DestinationBase {
}
/**
* Get the entity.
* Gets the entity.
*
* @param string $entity_type
* The entity type to retrieve.

View file

@ -3,8 +3,6 @@
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\destination\Config.
*
* Provides Configuration Management destination plugin.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
@ -18,6 +16,8 @@ use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides Configuration Management destination plugin.
*
* Persist data to the config system.
*
* When a property is NULL, the default is used unless the configuration option
@ -28,6 +28,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* )
*/
class Config extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface {
use DependencyTrait;
/**

View file

@ -5,7 +5,6 @@
* Contains \Drupal\migrate\Plugin\migrate\destination\DestinationBase.
*/
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Core\Plugin\PluginBase;
@ -113,4 +112,5 @@ abstract class DestinationBase extends PluginBase implements MigrateDestinationI
$this->rollbackAction = MigrateIdMapInterface::ROLLBACK_PRESERVE;
}
}
}

View file

@ -16,12 +16,15 @@ use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides entity destination plugin.
*
* @MigrateDestination(
* id = "entity",
* deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntity"
* )
*/
abstract class Entity extends DestinationBase implements ContainerFactoryPluginInterface, DependentPluginInterface {
use DependencyTrait;
/**
@ -77,16 +80,16 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
}
/**
* Finds the entity type from configuration or plugin id.
* Finds the entity type from configuration or plugin ID.
*
* @param string $plugin_id
* The plugin id.
* The plugin ID.
*
* @return string
* The entity type.
*/
protected static function getEntityTypeId($plugin_id) {
// Remove "entity:"
// Remove "entity:".
return substr($plugin_id, 7);
}
@ -103,10 +106,10 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
* @param \Drupal\migrate\Row $row
* The row object.
* @param array $old_destination_id_values
* The old destination ids.
* The old destination IDs.
*
* @return \Drupal\Core\Entity\EntityInterface
* The entity we're importing into.
* The entity we are importing into.
*/
protected function getEntity(Row $row, array $old_destination_id_values) {
$entity_id = $old_destination_id_values ? reset($old_destination_id_values) : $this->getEntityId($row);
@ -125,12 +128,13 @@ abstract class Entity extends DestinationBase implements ContainerFactoryPluginI
}
/**
* Get the entity id of the row.
* Gets the entity ID of the row.
*
* @param \Drupal\migrate\Row $row
* The row of data.
*
* @return string
* The entity id for the row we're importing.
* The entity ID for the row that we are importing.
*/
protected function getEntityId(Row $row) {
return $row->getDestinationProperty($this->getKey('id'));

View file

@ -10,6 +10,8 @@ namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\migrate\Row;
/**
* Provides entity base field override plugin.
*
* @MigrateDestination(
* id = "entity:base_field_override"
* )

View file

@ -18,7 +18,7 @@ use Drupal\migrate\Row;
*
* This class serves as the import class for most configuration entities.
* It can be necessary to provide a specific entity class if the configuration
* entity has a compound id (see EntityFieldEntity) or it has specific setter
* entity has a compound ID (see EntityFieldEntity) or it has specific setter
* methods (see EntityDateFormat). When implementing an entity destination for
* the latter case, make sure to add a test not only for importing but also
* for re-importing (if that is supported).
@ -39,14 +39,14 @@ class EntityConfigBase extends Entity {
// Ids is keyed by the key name so grab the keys.
$id_keys = array_keys($ids);
if (!$row->getDestinationProperty($id_key)) {
// Set the id into the destination in for form "val1.val2.val3".
// Set the ID into the destination in for form "val1.val2.val3".
$row->setDestinationProperty($id_key, $this->generateId($row, $id_keys));
}
}
$entity = $this->getEntity($row, $old_destination_id_values);
$entity->save();
if (count($ids) > 1) {
// This can only be a config entity, content entities have their id key
// This can only be a config entity, content entities have their ID key
// and that's it.
$return = array();
foreach ($id_keys as $id_key) {
@ -105,15 +105,15 @@ class EntityConfigBase extends Entity {
}
/**
* Generate an entity id.
* Generates an entity ID.
*
* @param \Drupal\migrate\Row $row
* The current row.
* @param array $ids
* The destination ids.
* The destination IDs.
*
* @return string
* The generated entity id.
* The generated entity ID.
*/
protected function generateId(Row $row, array $ids) {
$id_values = array();

View file

@ -7,15 +7,12 @@
namespace Drupal\migrate\Plugin\migrate\destination;
use Drupal\Component\Utility\Random;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\link\LinkItemInterface;
use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrateIdMapInterface;
@ -97,15 +94,15 @@ class EntityContentBase extends Entity {
}
/**
* Save the entity.
* Saves the entity.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The content entity.
* @param array $old_destination_id_values
* An array of destination id values.
* (optional) An array of destination ID values. Defaults to an empty array.
*
* @return array
* An array containing the entity id.
* An array containing the entity ID.
*/
protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array()) {
$entity->save();
@ -122,7 +119,7 @@ class EntityContentBase extends Entity {
}
/**
* Update an entity with the new values from row.
* Updates an entity with the new values from row.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to update.
@ -152,7 +149,7 @@ class EntityContentBase extends Entity {
}
/**
* Do as much population of the stub row as we can.
* Populates as much of the stub row as possible.
*
* @param \Drupal\migrate\Row $row
* The row of data.
@ -185,7 +182,6 @@ class EntityContentBase extends Entity {
if (is_null($values)) {
// Handle failure to generate a sample value.
throw new MigrateException('Stubbing failed, unable to generate value for field ' . $field_name);
break;
}
}

View file

@ -8,6 +8,8 @@
namespace Drupal\migrate\Plugin\migrate\destination;
/**
* Provides entity field instance plugin.
*
* @MigrateDestination(
* id = "entity:field_config"
* )

View file

@ -8,6 +8,8 @@
namespace Drupal\migrate\Plugin\migrate\destination;
/**
* Provides entity field storage configuration plugin.
*
* @MigrateDestination(
* id = "entity:field_storage_config"
* )

View file

@ -12,6 +12,8 @@ use Drupal\migrate\MigrateException;
use Drupal\migrate\Row;
/**
* Provides entity revision destination plugin.
*
* @MigrateDestination(
* id = "entity_revision",
* deriver = "Drupal\migrate\Plugin\Derivative\MigrateEntityRevision"
@ -28,12 +30,12 @@ class EntityRevision extends EntityContentBase {
}
/**
* Get the entity.
* Gets the entity.
*
* @param \Drupal\migrate\Row $row
* The row object.
* @param array $old_destination_id_values
* The old destination ids.
* The old destination IDs.
*
* @return \Drupal\Core\Entity\EntityInterface|false
* The entity or false if it can not be created.

View file

@ -8,6 +8,8 @@
namespace Drupal\migrate\Plugin\migrate\destination;
/**
* Provides entity view mode destination plugin.
*
* @MigrateDestination(
* id = "entity:entity_view_mode"
* )

View file

@ -11,6 +11,8 @@ use Drupal\migrate\Entity\MigrationInterface;
use Drupal\migrate\Row;
/**
* Provides null destination plugin.
*
* @MigrateDestination(
* id = "null",
* requirements_met = false

View file

@ -69,6 +69,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
protected $database;
/**
* The select query.
*
* @var \Drupal\Core\Database\Query\SelectInterface
*/
protected $query;
@ -300,7 +302,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
$fields = $source_id_schema;
// Add destination identifiers to map table.
// TODO: How do we discover the destination schema?
// @todo How do we discover the destination schema?
$count = 1;
foreach ($this->migration->getDestinationPlugin()->getIds() as $id_definition) {
// Allow dest identifier fields to be NULL (for IGNORED/FAILED
@ -383,35 +385,40 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
// Add any missing columns to the map table.
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName,
'rollback_action')) {
$this->getDatabase()->schema()->addField($this->mapTableName,
'rollback_action', array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
));
$this->getDatabase()->schema()->addField($this->mapTableName, 'rollback_action',
array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'Flag indicating what to do for this item on rollback',
)
);
}
if (!$this->getDatabase()->schema()->fieldExists($this->mapTableName, 'hash')) {
$this->getDatabase()->schema()->addField($this->mapTableName, 'hash', array(
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
));
$this->getDatabase()->schema()->addField($this->mapTableName, 'hash',
array(
'type' => 'varchar',
'length' => '64',
'not null' => FALSE,
'description' => 'Hash of source row data, for detecting changes',
)
);
}
}
}
/**
* Create schema from an id definition.
* Creates schema from an ID definition.
*
* @param array $id_definition
* A field schema definition. Can be SQL schema or a type data
* based schema. In the latter case, the value of type needs to be
* $typed_data_type.$column
* $typed_data_type.$column.
*
* @return array
* The schema definition.
*/
protected function getFieldSchema(array $id_definition) {
$type_parts = explode('.', $id_definition['type']);
@ -593,8 +600,8 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
*/
public function prepareUpdate() {
$this->getDatabase()->update($this->mapTableName())
->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
->execute();
->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
->execute();
}
/**
@ -642,10 +649,11 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
/**
* Counts records in a table.
*
* @param $status
* @param int $status
* An integer for the source_row_status column.
* @param $table
* The table to work
* @param string $table
* (optional) The table to work. Defaults to NULL.
*
* @return int
* The number of records.
*/
@ -779,7 +787,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
}
/**
* @inheritdoc
* {@inheritdoc}
*/
public function currentDestination() {
if ($this->valid()) {

View file

@ -22,6 +22,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class DedupeEntity extends DedupeBase implements ContainerFactoryPluginInterface {
/**
* The entity query factory.
*
* @var \Drupal\Core\Entity\Query\QueryFactoryInterface
*/
protected $entityQueryFactory;

View file

@ -11,7 +11,6 @@ use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
/**
* This plugin sets missing values on the destination.
*
@ -30,4 +29,5 @@ class DefaultValue extends ProcessPluginBase {
}
return $value ?: $this->configuration['default_value'];
}
}

View file

@ -34,4 +34,5 @@ class Flatten extends ProcessPluginBase {
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
return iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($value)), FALSE);
}
}

View file

@ -21,6 +21,8 @@ use Drupal\migrate\Row;
class Get extends ProcessPluginBase {
/**
* Flag indicating whether there are multiple values.
*
* @var bool
*/
protected $multiple;
@ -69,4 +71,5 @@ class Get extends ProcessPluginBase {
public function multiple() {
return $this->multiple;
}
}

View file

@ -65,4 +65,5 @@ class Iterator extends ProcessPluginBase {
public function multiple() {
return TRUE;
}
}

View file

@ -29,6 +29,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class MachineName extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* The transliteration service.
*
* @var \Drupal\Component\Transliteration\TransliterationInterface
*/
protected $transliteration;
@ -37,13 +39,13 @@ class MachineName extends ProcessPluginBase implements ContainerFactoryPluginInt
* Constructs a MachineName plugin.
*
* @param array $configuration
* The plugin configuration.
* The plugin configuration.
* @param string $plugin_id
* The plugin ID.
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* The plugin definition.
* @param \Drupal\Component\Transliteration\TransliterationInterface $transliteration
* The transliteration service.
* The transliteration service.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, TransliterationInterface $transliteration) {
parent::__construct($configuration, $plugin_id, $plugin_definition);

View file

@ -0,0 +1,109 @@
<?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\MigrateExecutableInterface;
use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* This plugin figures out menu link parent plugin IDs.
*
* @MigrateProcessPlugin(
* id = "menu_link_parent"
* )
*/
class MenuLinkParent extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* @var \Drupal\Core\Menu\MenuLinkManagerInterface
*/
protected $menuLinkManager;
/**
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
*/
protected $migrationPlugin;
/**
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $menuLinkStorage;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateProcessInterface $migration_plugin, MenuLinkManagerInterface $menu_link_manager, EntityStorageInterface $menu_link_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migrationPlugin = $migration_plugin;
$this->menuLinkManager = $menu_link_manager;
$this->menuLinkStorage = $menu_link_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$migration_configuration['migration'][] = $migration->id();
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration),
$container->get('plugin.manager.menu.link'),
$container->get('entity.manager')->getStorage('menu_link_content')
);
}
/**
* {@inheritdoc}
*
* Find the parent link GUID.
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$parent_id = array_shift($value);
if (!$parent_id) {
// Top level item.
return '';
}
try {
$already_migrated_id = $this
->migrationPlugin
->transform($parent_id, $migrate_executable, $row, $destination_property);
if ($already_migrated_id && ($link = $this->menuLinkStorage->load($already_migrated_id))) {
return $link->getPluginId();
}
}
catch (MigrateSkipRowException $e) {
}
if (isset($value[1])) {
list($menu_name, $parent_link_path) = $value;
$url = Url::fromUserInput("/$parent_link_path");
if ($url->isRouted()) {
$links = $this->menuLinkManager->loadLinksByRoute($url->getRouteName(), $url->getRouteParameters(), $menu_name);
if (count($links) == 1) {
/** @var \Drupal\Core\Menu\MenuLinkInterface $link */
$link = reset($links);
return $link->getPluginId();
}
}
}
throw new MigrateSkipRowException;
}
}

View file

@ -5,7 +5,6 @@
* Contains \Drupal\migrate\Plugin\migrate\process\Migration.
*/
namespace Drupal\migrate\Plugin\migrate\process;
use Drupal\Core\Entity\EntityStorageInterface;
@ -28,11 +27,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class Migration extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* The process plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $processPluginManager;
/**
* The entity storage manager.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $migrationStorage;
@ -115,7 +118,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
// Only keep the process necessary to produce the destination ID.
$process = $migration->get('process');
// We already have the source id values but need to key them for the Row
// We already have the source ID values but need to key them for the Row
// constructor.
$source_ids = $migration->getSourcePlugin()->getIds();
$values = array();
@ -148,7 +151,7 @@ class Migration extends ProcessPluginBase implements ContainerFactoryPluginInter
}
/**
* Skip the migration process entirely if the value is FALSE.
* Skips the migration process entirely if the value is FALSE.
*
* @param mixed $value
* The incoming value to transform.

View file

@ -1,4 +1,5 @@
<?php
/**
* @file
* Contains \Drupal\migrate\Plugin\migrate\process\Route.
@ -22,6 +23,8 @@ use Drupal\migrate\Row;
class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* The path validator service.
*
* @var \Drupal\Core\Path\PathValidatorInterface
*/
protected $pathValidator;
@ -29,10 +32,10 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, PathValidatorInterface $pathValidator) {
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, PathValidatorInterface $path_validator) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migration = $migration;
$this->pathValidator = $pathValidator;
$this->pathValidator = $path_validator;
}
/**
@ -60,7 +63,7 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
if ($extracted) {
if ($extracted->isExternal()) {
$route['route_name'] = null;
$route['route_name'] = NULL;
$route['route_parameters'] = array();
$route['options'] = $options;
$route['url'] = $extracted->getUri();
@ -83,7 +86,7 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
unset($route['options']['query']);
}
$route['options'] = $route['options'] + $options;
$route['url'] = null;
$route['url'] = NULL;
}
}
@ -91,4 +94,3 @@ class Route extends ProcessPluginBase implements ContainerFactoryPluginInterface
}
}

View file

@ -8,10 +8,12 @@
namespace Drupal\migrate\Plugin\migrate\source;
/**
* Provides a dummy select query object for source plugins.
*
* Trait providing a dummy select query object for source plugins based on
* SqlBase which override initializeIterator() to obtain their data from other
* SqlBase services instead of a direct query. This ensures that query() returns
* a valid object, even though it isn't used for iteration.
* a valid object, even though it is not used for iteration.
*/
trait DummyQueryTrait {
@ -19,7 +21,8 @@ trait DummyQueryTrait {
* {@inheritdoc}
*/
public function query() {
// Pass an arbritrary table name - the query should never be executed anyway.
// Pass an arbritrary table name - the query should never be executed
// anyway.
$query = $this->select(uniqid(), 's')
->range(0, 1);
$query->addExpression('1');

View file

@ -34,6 +34,9 @@ class EmptySource extends SourcePluginBase {
return new \ArrayIterator(array(array('id' => '')));
}
/**
* Allows class to decide how it will react when it is treated like a string.
*/
public function __toString() {
return '';
}

View file

@ -28,11 +28,15 @@ use Drupal\migrate\Row;
abstract class SourcePluginBase extends PluginBase implements MigrateSourceInterface {
/**
* The module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The entity migration object.
*
* @var \Drupal\migrate\Entity\MigrationInterface
*/
protected $migration;
@ -47,14 +51,14 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
protected $highWaterProperty;
/**
* The current row from the query
* The current row from the query.
*
* @var \Drupal\Migrate\Row
*/
protected $currentRow;
/**
* The primary key of the current row
* The primary key of the current row.
*
* @var array
*/
@ -92,6 +96,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
protected $skipCount = FALSE;
/**
* Flags whether to track changes to incloming data.
*
* If TRUE, we will maintain hashed source rows to determine whether incoming
* data has changed.
*
@ -100,6 +106,8 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
protected $trackChanges = FALSE;
/**
* Flags whether source plugin will read the map row and add to data row.
*
* By default, next() will directly read the map row and add it to the data
* row. A source plugin implementation may do this itself (in particular, the
* SQL source can incorporate the map table into the query) - if so, it should
@ -110,16 +118,22 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
protected $mapRowAdded = FALSE;
/**
* The backend cache.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cache;
/**
* The migration ID map.
*
* @var \Drupal\migrate\Plugin\MigrateIdMapInterface
*/
protected $idMap;
/**
* The iterator to iterate over the source rows.
*
* @var \Iterator
*/
protected $iterator;
@ -150,7 +164,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
}
/**
* Initialize the iterator with the source data.
* Initializes the iterator with the source data.
*
* @return array
* An array of the data for this source.
@ -158,7 +172,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
protected abstract function initializeIterator();
/**
* Get the module handler.
* Gets the module handler.
*
* @return \Drupal\Core\Extension\ModuleHandlerInterface
* The module handler.
@ -212,6 +226,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
* Returns the iterator that will yield the row arrays to be processed.
*
* @return \Iterator
* The iterator that will yield the row arrays to be processed.
*/
protected function getIterator() {
if (!isset($this->iterator)) {
@ -228,7 +243,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
}
/**
* Get the iterator key.
* Gets the iterator key.
*
* Implementation of Iterator::key - called when entering a loop iteration,
* returning the key of the current row. It must be a scalar - we will
@ -240,17 +255,17 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
}
/**
* Whether the iterator is currently valid.
* Checks whether the iterator is currently valid.
*
* Implementation of Iterator::valid() - called at the top of the loop,
* returning TRUE to process the loop and FALSE to terminate it
* returning TRUE to process the loop and FALSE to terminate it.
*/
public function valid() {
return isset($this->currentRow);
}
/**
* Rewind the iterator.
* Rewinds the iterator.
*
* Implementation of Iterator::rewind() - subclasses of MigrateSource should
* implement performRewind() to do any class-specific setup for iterating
@ -311,14 +326,14 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
// 2. Explicitly set to update.
// 3. The row is newer than the current highwater mark.
// 4. If no such property exists then try by checking the hash of the row.
if (!$row->getIdMap() || $row->needsUpdate() || $this->aboveHighwater($row) || $this->rowChanged($row) ) {
if (!$row->getIdMap() || $row->needsUpdate() || $this->aboveHighwater($row) || $this->rowChanged($row)) {
$this->currentRow = $row->freezeSource();
}
}
}
/**
* Check if the incoming data is newer than what we've previously imported.
* Checks if the incoming data is newer than what we've previously imported.
*
* @param \Drupal\migrate\Row $row
* The row we're importing.
@ -331,7 +346,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
}
/**
* Check if the incoming row has changed since our last import.
* Checks if the incoming row has changed since our last import.
*
* @param \Drupal\migrate\Row $row
* The row we're importing.
@ -344,20 +359,20 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
}
/**
* Getter for currentSourceIds data member.
* Gets the currentSourceIds data member.
*/
public function getCurrentIds() {
return $this->currentSourceIds;
}
/**
* Get the source count.
* Gets the source count.
*
* Return a count of available source records, from the cache if appropriate.
* Returns -1 if the source is not countable.
*
* @param bool $refresh
* Whether or not to refresh the count.
* (optional) Whether or not to refresh the count. Defaults to FALSE.
*
* @return int
* The count.
@ -395,7 +410,7 @@ abstract class SourcePluginBase extends PluginBase implements MigrateSourceInter
}
/**
* Get the cache object.
* Gets the cache object.
*
* @return \Drupal\Core\Cache\CacheBackendInterface
* The cache object.

View file

@ -27,11 +27,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPluginInterface {
/**
* The query string.
*
* @var \Drupal\Core\Database\Query\SelectInterface
*/
protected $query;
/**
* The database object.
*
* @var \Drupal\Core\Database\Connection
*/
protected $database;
@ -65,7 +69,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
}
/**
* Print the query string when the object is used a string.
* Prints the query string when the object is used as a string.
*
* @return string
* The query string.
@ -75,7 +79,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
}
/**
* Get the database connection object.
* Gets the database connection object.
*
* @return \Drupal\Core\Database\Connection
* The database connection.
@ -95,8 +99,9 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
}
/**
* Get a connection to the referenced database, adding the connection if
* necessary.
* Gets a connection to the referenced database.
*
* This method will add the database connection if necessary.
*
* @param array $database_info
* Configuration for the source database connection. The keys are:
@ -136,7 +141,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
}
/**
* A helper for adding tags and metadata to the query.
* Adds tags and metadata to the query.
*
* @return \Drupal\Core\Database\Query\SelectInterface
* The query with additional tags and metadata.
@ -164,8 +169,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
$keys = array();
// The rules for determining what conditions to add to the query are as
// follows (applying first applicable rule)
// follows (applying first applicable rule):
// 1. If the map is joinable, join it. We will want to accept all rows
// which are either not in the map, or marked in the map as NEEDS_UPDATE.
// Note that if high water fields are in play, we want to accept all rows
@ -241,7 +245,7 @@ abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPlugi
}
/**
* Check if we can join against the map table.
* Checks if we can join against the map table.
*
* This function specifically catches issues when we're migrating with
* unique sets of credentials for the source and destination database.