Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -2,12 +2,13 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\builder\d6\CckBuilder.
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\builder\CckBuilder.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\builder\d6;
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\builder;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -24,6 +25,13 @@ abstract class CckBuilder extends BuilderBase implements ContainerFactoryPluginI
|
|||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Already-instantiated cckfield plugins, keyed by ID.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
|
||||
*/
|
||||
protected $cckPluginCache = [];
|
||||
|
||||
/**
|
||||
* Constructs a CckBuilder.
|
||||
*
|
||||
|
@ -53,4 +61,22 @@ abstract class CckBuilder extends BuilderBase implements ContainerFactoryPluginI
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cckfield plugin instance.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type (plugin ID).
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface|NULL $migration
|
||||
* The migration, if any.
|
||||
*
|
||||
* @return \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
|
||||
* The cckfield plugin instance.
|
||||
*/
|
||||
protected function getCckPlugin($field_type, MigrationInterface $migration = NULL) {
|
||||
if (empty($this->cckPluginCache[$field_type])) {
|
||||
$this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $migration);
|
||||
}
|
||||
return $this->cckPluginCache[$field_type];
|
||||
}
|
||||
|
||||
}
|
|
@ -8,6 +8,9 @@
|
|||
namespace Drupal\migrate_drupal\Plugin\migrate\builder\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\builder\CckBuilder;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_cck_migration")
|
||||
|
@ -27,8 +30,20 @@ class CckMigration extends CckBuilder {
|
|||
public function buildMigrations(array $template) {
|
||||
$migration = Migration::create($template);
|
||||
|
||||
$source_plugin = $migration->getSourcePlugin();
|
||||
// The source plugin will throw RequirementsException if CCK is not enabled,
|
||||
// in which case there is nothing else for us to do.
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
try {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
return [$migration];
|
||||
}
|
||||
}
|
||||
|
||||
// Loop through every field that will be migrated.
|
||||
foreach ($migration->getSourcePlugin() as $field) {
|
||||
foreach ($source_plugin as $field) {
|
||||
$field_type = $field->getSourceProperty('type');
|
||||
|
||||
// Each field type should only be processed once.
|
||||
|
|
|
@ -11,6 +11,7 @@ use Drupal\Component\Plugin\DependentPluginInterface;
|
|||
use Drupal\Core\Entity\DependencyTrait;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\migrate\source\SqlBase;
|
||||
|
@ -51,8 +52,8 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state);
|
||||
$this->entityManager = $entity_manager;
|
||||
}
|
||||
|
||||
|
@ -89,6 +90,7 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
|
|||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('state'),
|
||||
$container->get('entity.manager')
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
|
||||
/**
|
||||
|
@ -32,8 +33,8 @@ class Variable extends DrupalSqlBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $entity_manager);
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->variables = $this->configuration['variables'];
|
||||
}
|
||||
|
||||
|
@ -53,7 +54,10 @@ class Variable extends DrupalSqlBase {
|
|||
* Only those values are returned that are actually in the database.
|
||||
*/
|
||||
protected function values() {
|
||||
return array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
|
||||
// Create an ID field so we can record migration in the map table.
|
||||
// Arbitrarily, use the first variable name.
|
||||
$values['id'] = reset($this->variables);
|
||||
return $values + array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +88,8 @@ class Variable extends DrupalSqlBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array();
|
||||
$ids['id']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue