Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023
This commit is contained in:
parent
2720a9ec4b
commit
f3791f1da3
1898 changed files with 54300 additions and 11481 deletions
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\builder\d6\CckBuilder.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\builder\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Plugin\migrate\builder\BuilderBase;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Base class for builders which leverage cckfield plugins.
|
||||
*/
|
||||
abstract class CckBuilder extends BuilderBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The cckfield plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigratePluginManager
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Constructs a CckBuilder.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $cck_manager
|
||||
* The cckfield plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigratePluginManager $cck_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->cckPluginManager = $cck_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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.migrate.cckfield')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\builder\d6\CckMigration.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\builder\d6;
|
||||
|
||||
use Drupal\migrate\Entity\Migration;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_cck_migration")
|
||||
*/
|
||||
class CckMigration extends CckBuilder {
|
||||
|
||||
/**
|
||||
* List of cckfield plugin IDs which have already run.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $processedFieldTypes = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildMigrations(array $template) {
|
||||
$migration = Migration::create($template);
|
||||
|
||||
// Loop through every field that will be migrated.
|
||||
foreach ($migration->getSourcePlugin() as $field) {
|
||||
$field_type = $field->getSourceProperty('type');
|
||||
|
||||
// Each field type should only be processed once.
|
||||
if (in_array($field_type, $this->processedFieldTypes)) {
|
||||
continue;
|
||||
}
|
||||
// Only process the current field type if a relevant cckfield plugin
|
||||
// exists.
|
||||
elseif ($this->cckPluginManager->hasDefinition($field_type)) {
|
||||
$this->processedFieldTypes[] = $field_type;
|
||||
// Allow the cckfield plugin to alter the migration as necessary so that
|
||||
// it knows how to handle fields of this type.
|
||||
$this->cckPluginManager
|
||||
->createInstance($field_type, [], $migration)
|
||||
->{$this->configuration['cck_plugin_method']}($migration);
|
||||
}
|
||||
}
|
||||
|
||||
return [$migration];
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace Drupal\migrate_drupal\Plugin\migrate\destination;
|
|||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Field\FieldTypePluginManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\migrate_drupal\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\migrate\destination\EntityFieldStorageConfig as BaseEntityFieldStorageConfig;
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
|||
use Drupal\Component\Plugin\DependentPluginInterface;
|
||||
use Drupal\Core\Entity\DependencyTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\migrate_drupal\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\migrate\source\EmptySource as BaseEmptySource;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Base class for D7 source plugins which need to collect field values from
|
||||
* the Field API.
|
||||
*/
|
||||
abstract class FieldableEntity extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* Returns all non-deleted field instances attached to a specific entity type.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* The entity type ID.
|
||||
* @param string|NULL $bundle
|
||||
* (optional) The bundle.
|
||||
*
|
||||
* @return array[]
|
||||
* The field instances, keyed by field name.
|
||||
*/
|
||||
protected function getFields($entity_type, $bundle = NULL) {
|
||||
return $this->select('field_config_instance', 'fci')
|
||||
->fields('fci')
|
||||
->condition('entity_type', $entity_type)
|
||||
->condition('bundle', isset($bundle) ? $bundle : $entity_type)
|
||||
->condition('deleted', 0)
|
||||
->execute()
|
||||
->fetchAllAssoc('field_name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves field values for a single field of a single entity.
|
||||
*
|
||||
* @param string $entity_type
|
||||
* The entity type.
|
||||
* @param string $field
|
||||
* The field name.
|
||||
* @param int $entity_id
|
||||
* The entity ID.
|
||||
* @param int|null $revision_id
|
||||
* (optional) The entity revision ID.
|
||||
*
|
||||
* @return array
|
||||
* The raw field values, keyed by delta.
|
||||
*
|
||||
* @todo Support multilingual field values.
|
||||
*/
|
||||
protected function getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL) {
|
||||
$table = (isset($revision_id) ? 'field_revision_' : 'field_data_') . $field;
|
||||
$query = $this->select($table, 't')
|
||||
->fields('t')
|
||||
->condition('entity_type', $entity_type)
|
||||
->condition('entity_id', $entity_id)
|
||||
->condition('deleted', 0);
|
||||
if (isset($revision_id)) {
|
||||
$query->condition('revision_id', $revision_id);
|
||||
}
|
||||
$values = [];
|
||||
foreach ($query->execute() as $row) {
|
||||
foreach ($row as $key => $value) {
|
||||
$delta = $row['delta'];
|
||||
if (strpos($key, $field) === 0) {
|
||||
$column = substr($key, strlen($field) + 1);
|
||||
$values[$delta][$column] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue