Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
38
core/modules/migrate_drupal/src/Entity/Migration.php
Normal file
38
core/modules/migrate_drupal/src/Entity/Migration.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Entity\Migration.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Entity;
|
||||
|
||||
use Drupal\migrate\Entity\Migration as BaseMigration;
|
||||
|
||||
class Migration extends BaseMigration implements MigrationInterface {
|
||||
|
||||
/**
|
||||
* The load plugin configuration, if any.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $load = array();
|
||||
|
||||
/**
|
||||
* The load plugin.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateLoadInterface|false
|
||||
*/
|
||||
protected $loadPlugin = FALSE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLoadPlugin() {
|
||||
if ($this->load && !$this->loadPlugin) {
|
||||
$this->loadPlugin = \Drupal::service('plugin.manager.migrate.load')->createInstance($this->load['plugin'], $this->load, $this);
|
||||
}
|
||||
return $this->loadPlugin;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Entity\MigrationInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Entity;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface as BaseMigrationInterface;
|
||||
|
||||
interface MigrationInterface extends BaseMigrationInterface {
|
||||
|
||||
/**
|
||||
* Returns the initialized load plugin if there's one.
|
||||
*
|
||||
* @return \Drupal\migrate_drupal\Plugin\MigrateLoadInterface|false
|
||||
*/
|
||||
public function getLoadPlugin();
|
||||
|
||||
}
|
237
core/modules/migrate_drupal/src/MigrationStorage.php
Normal file
237
core/modules/migrate_drupal/src/MigrationStorage.php
Normal file
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\MigrationStorage.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Uuid\UuidInterface;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityStorageException;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Language\LanguageManagerInterface;
|
||||
use Drupal\migrate\Plugin\migrate\source\SourcePluginBase;
|
||||
use Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface;
|
||||
use Drupal\migrate\MigrationStorage as BaseMigrationStorage;
|
||||
use Drupal\migrate_drupal\Plugin\MigratePluginManager;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Storage for migration entities.
|
||||
*/
|
||||
class MigrationStorage extends BaseMigrationStorage {
|
||||
|
||||
/**
|
||||
* A cached array of cck field plugins.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $cckFieldPlugins;
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigratePluginManager
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Constructs a MigrationStorage object.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The config factory service.
|
||||
* @param \Drupal\Component\Uuid\UuidInterface $uuid_service
|
||||
* The UUID service.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\migrate_drupal\Plugin\MigratePluginManager
|
||||
* The cckfield plugin manager.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, MigratePluginManager $cck_plugin_manager) {
|
||||
parent::__construct($entity_type, $config_factory, $uuid_service, $language_manager);
|
||||
$this->cckPluginManager = $cck_plugin_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('config.factory'),
|
||||
$container->get('uuid'),
|
||||
$container->get('language_manager'),
|
||||
$container->get('plugin.manager.migrate.cckfield')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMultiple(array $ids = NULL) {
|
||||
$ids_to_load = array();
|
||||
$dynamic_ids = array();
|
||||
if (isset($ids)) {
|
||||
foreach ($ids as $id) {
|
||||
// Evaluate whether or not this migration is dynamic in the form of
|
||||
// migration_id:* to load all the additional migrations.
|
||||
if (($n = strpos($id, ':')) !== FALSE) {
|
||||
$base_id = substr($id, 0, $n);
|
||||
$ids_to_load[] = $base_id;
|
||||
// Get the ids of the additional migrations.
|
||||
$sub_id = substr($id, $n + 1);
|
||||
if ($sub_id == '*') {
|
||||
// If the id of the additional migration is '*', get all of them.
|
||||
$dynamic_ids[$base_id] = NULL;
|
||||
}
|
||||
elseif (!isset($dynamic_ids[$base_id]) || is_array($dynamic_ids[$base_id])) {
|
||||
$dynamic_ids[$base_id][] = $sub_id;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ids_to_load[] = $id;
|
||||
}
|
||||
}
|
||||
$ids = array_flip($ids);
|
||||
}
|
||||
else {
|
||||
$ids_to_load = NULL;
|
||||
}
|
||||
|
||||
/** @var \Drupal\migrate_drupal\Entity\MigrationInterface[] $entities */
|
||||
$entities = parent::loadMultiple($ids_to_load);
|
||||
if (!isset($ids)) {
|
||||
// Changing the array being foreach()'d is not a good idea.
|
||||
$return = array();
|
||||
foreach ($entities as $entity_id => $entity) {
|
||||
if ($plugin = $entity->getLoadPlugin()) {
|
||||
$new_entities = $plugin->loadMultiple($this);
|
||||
$this->postLoad($new_entities);
|
||||
$this->getDynamicIds($dynamic_ids, $new_entities);
|
||||
$return += $new_entities;
|
||||
}
|
||||
else {
|
||||
$return[$entity_id] = $entity;
|
||||
}
|
||||
}
|
||||
$entities = $return;
|
||||
}
|
||||
else {
|
||||
foreach ($dynamic_ids as $base_id => $sub_ids) {
|
||||
$entity = $entities[$base_id];
|
||||
if ($plugin = $entity->getLoadPlugin()) {
|
||||
unset($entities[$base_id]);
|
||||
$new_entities = $plugin->loadMultiple($this, $sub_ids);
|
||||
$this->postLoad($new_entities);
|
||||
if (!isset($sub_ids)) {
|
||||
unset($dynamic_ids[$base_id]);
|
||||
$this->getDynamicIds($dynamic_ids, $new_entities);
|
||||
}
|
||||
$entities += $new_entities;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allow modules providing cck field plugins to alter the required
|
||||
// migrations to assist with the migration a custom field type.
|
||||
$this->applyCckFieldProcessors($entities);
|
||||
|
||||
// Build an array of dependencies and set the order of the migrations.
|
||||
return $this->buildDependencyMigration($entities, $dynamic_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the dynamic id mapping from entities loaded by plugin.
|
||||
*
|
||||
* @param array $dynamic_ids
|
||||
* Get the dynamic migration ids.
|
||||
* @param array $entities
|
||||
* An array of entities.
|
||||
*/
|
||||
protected function getDynamicIds(array &$dynamic_ids, array $entities) {
|
||||
foreach (array_keys($entities) as $new_id) {
|
||||
list($base_id, $sub_id) = explode(':', $new_id, 2);
|
||||
$dynamic_ids[$base_id][] = $sub_id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(EntityInterface $entity) {
|
||||
if (strpos($entity->id(), ':') !== FALSE) {
|
||||
throw new EntityStorageException(SafeMarkup::format("Dynamic migration %id can't be saved", array('$%id' => $entity->id())));
|
||||
}
|
||||
return parent::save($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow any field type plugins to adjust the migrations as required.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\Migration[] $entities
|
||||
* An array of migration entities.
|
||||
*/
|
||||
protected function applyCckFieldProcessors(array $entities) {
|
||||
$method_map = $this->getMigrationPluginMethodMap();
|
||||
|
||||
foreach ($entities as $entity_id => $migration) {
|
||||
// Allow field plugins to process the required migrations.
|
||||
if (isset($method_map[$entity_id])) {
|
||||
$method = $method_map[$entity_id];
|
||||
$cck_plugins = $this->getCckFieldPlugins();
|
||||
|
||||
array_walk($cck_plugins, function ($plugin) use ($method, $migration) {
|
||||
$plugin->$method($migration);
|
||||
});
|
||||
}
|
||||
|
||||
// If this is a CCK bundle migration, allow the cck field plugins to add
|
||||
// any field type processing.
|
||||
$source_plugin = $migration->getSourcePlugin();
|
||||
if ($source_plugin instanceof CckFieldMigrateSourceInterface && strpos($entity_id, SourcePluginBase::DERIVATIVE_SEPARATOR)) {
|
||||
$plugins = $this->getCckFieldPlugins();
|
||||
foreach ($source_plugin->fieldData() as $field_name => $data) {
|
||||
if (isset($plugins[$data['type']])) {
|
||||
$plugins[$data['type']]->processCckFieldValues($migration, $field_name, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of loaded cck field plugins.
|
||||
*
|
||||
* @return \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
|
||||
* An array of cck field process plugins.
|
||||
*/
|
||||
protected function getCckFieldPlugins() {
|
||||
if (!isset($this->cckFieldPlugins)) {
|
||||
$this->cckFieldPlugins = [];
|
||||
foreach ($this->cckPluginManager->getDefinitions() as $definition) {
|
||||
$this->cckFieldPlugins[$definition['id']] = $this->cckPluginManager->createInstance($definition['id']);
|
||||
}
|
||||
}
|
||||
return $this->cckFieldPlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a map between migration ids and the cck field plugin method.
|
||||
*
|
||||
* @return array
|
||||
* The map between migrations and cck field plugin processing methods.
|
||||
*/
|
||||
protected function getMigrationPluginMethodMap() {
|
||||
return [
|
||||
'd6_field' => 'processField',
|
||||
'd6_field_instance' => 'processFieldInstance',
|
||||
'd6_field_instance_widget_settings' => 'processFieldWidget',
|
||||
'd6_field_formatter_settings' => 'processFieldFormatter',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrateSourceInterface;
|
||||
|
||||
/**
|
||||
* Defines an interface for cck field sources that need per type processing.
|
||||
*/
|
||||
interface CckFieldMigrateSourceInterface extends MigrateSourceInterface {
|
||||
|
||||
/**
|
||||
* Field data used for determining the field type in the LoadEntity
|
||||
*
|
||||
* @return mixed
|
||||
* An array of cck field data.
|
||||
*/
|
||||
public function fieldData();
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
|
||||
/**
|
||||
* Provides an interface for all CCK field type plugins.
|
||||
*/
|
||||
interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processField(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field instance migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field widget migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldWidget(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field formatter migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldFormatter(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Get a map between D6 formatters and D8 formatters for this field type.
|
||||
*
|
||||
* This is used by static::processFieldFormatter() in the base class.
|
||||
*
|
||||
* @return array
|
||||
* The keys are D6 formatters and the values are D8 formatters.
|
||||
*/
|
||||
public function getFieldFormatterMap();
|
||||
|
||||
/**
|
||||
* Get a map between D6 and D8 widgets for this field type.
|
||||
*
|
||||
* @return array
|
||||
* The keys are D6 field widget types and the values D8 widgets.
|
||||
*/
|
||||
public function getFieldWidgetMap();
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the cck bundle migrations.
|
||||
*
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
* @param string $field_name
|
||||
* The field name we're processing the value for.
|
||||
* @param array $data
|
||||
* The array of field data from CckFieldValues::fieldData().
|
||||
*/
|
||||
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data);
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\MigrateLoadInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
|
||||
/**
|
||||
* Defines an interface for migration load plugins.
|
||||
*
|
||||
* @see \Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
interface MigrateLoadInterface extends PluginInspectionInterface {
|
||||
|
||||
/**
|
||||
* Load an additional migration.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
|
||||
* The migration storage.
|
||||
* @param string $sub_id
|
||||
* For example, when loading d6_node:article, this will be article.
|
||||
* @return \Drupal\migrate\Entity\MigrationInterface
|
||||
*/
|
||||
public function load(EntityStorageInterface $storage, $sub_id);
|
||||
|
||||
/**
|
||||
* Load additional migrations.
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
|
||||
* The migration storage.
|
||||
* @param array $sub_ids
|
||||
* For example, when loading d6_node:article, sub_id will be article.
|
||||
* If NULL then load all sub-migrations.
|
||||
* @return \Drupal\migrate\Entity\MigrationInterface[]
|
||||
*/
|
||||
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL);
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\MigratePluginManager.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\migrate\Plugin\MigratePluginManager as BaseMigratePluginManager;
|
||||
|
||||
/**
|
||||
* Manages migrate_drupal plugins.
|
||||
*
|
||||
* @see plugin_api
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
class MigratePluginManager extends BaseMigratePluginManager {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getPluginInterfaceMap() {
|
||||
return parent::getPluginInterfaceMap() + [
|
||||
'load' => 'Drupal\migrate_drupal\Plugin\MigrateLoadInterface',
|
||||
'cckfield' => 'Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
|
||||
|
||||
/**
|
||||
* The base class for all cck field plugins.
|
||||
*
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigratePluginManager
|
||||
* @see \Drupal\migrate_drupal\Annotation\MigrateCckField
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
|
||||
* @see plugin_api
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
abstract class CckFieldPluginBase extends PluginBase implements MigrateCckFieldInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processField(MigrationInterface $migration) {
|
||||
$process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId;
|
||||
$migration->mergeProcessOfProperty('type', $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration) {
|
||||
// Nothing to do by default with field instances.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldWidget(MigrationInterface $migration) {
|
||||
$process = [];
|
||||
foreach ($this->getFieldWidgetMap() as $source_widget => $destination_widget) {
|
||||
$process['type']['map'][$source_widget] = $destination_widget;
|
||||
}
|
||||
$migration->mergeProcessOfProperty('options/type', $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldWidgetMap() {
|
||||
// By default use the plugin id for the widget types.
|
||||
return [
|
||||
$this->pluginId => $this->pluginId . '_default',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldFormatter(MigrationInterface $migration) {
|
||||
$process = [];
|
||||
foreach ($this->getFieldFormatterMap() as $source_format => $destination_format) {
|
||||
$process[0]['map'][$this->pluginId][$source_format] = $destination_format;
|
||||
}
|
||||
$migration->mergeProcessOfProperty('options/type', $process);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\LinkField.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
|
||||
/**
|
||||
* @PluginID("link")
|
||||
*/
|
||||
class LinkField extends CckFieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
// See d6_field_formatter_settings.yml and CckFieldPluginBase
|
||||
// processFieldFormatter().
|
||||
return [
|
||||
'default' => 'link',
|
||||
'plain' => 'link',
|
||||
'absolute' => 'link',
|
||||
'title_plain' => 'link',
|
||||
'url' => 'link',
|
||||
'short' => 'link',
|
||||
'label' => 'link',
|
||||
'separate' => 'link_separate',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'd6_cck_link',
|
||||
'source' => [
|
||||
$field_name,
|
||||
$field_name . '_title',
|
||||
$field_name . '_attributes',
|
||||
],
|
||||
];
|
||||
$migration->mergeProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\destination\EntityFieldStorageConfig.
|
||||
*/
|
||||
|
||||
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\Plugin\migrate\destination\EntityFieldStorageConfig as BaseEntityFieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Destination with Drupal specific config dependencies.
|
||||
*
|
||||
* @MigrateDestination(
|
||||
* id = "md_entity:field_storage_config"
|
||||
* )
|
||||
*/
|
||||
class EntityFieldStorageConfig extends BaseEntityFieldStorageConfig {
|
||||
|
||||
/**
|
||||
* The field type plugin manager.
|
||||
*
|
||||
* @var \Drupal\Core\Field\FieldTypePluginManagerInterface
|
||||
*/
|
||||
protected $fieldTypePluginManager;
|
||||
|
||||
/**
|
||||
* Construct a new plugin.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param MigrationInterface $migration
|
||||
* The migration.
|
||||
* @param EntityStorageInterface $storage
|
||||
* The storage for this entity type.
|
||||
* @param array $bundles
|
||||
* The list of bundles this entity type has.
|
||||
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager
|
||||
* The field type plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, FieldTypePluginManagerInterface $field_type_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles);
|
||||
$this->fieldTypePluginManager = $field_type_plugin_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
$entity_type_id = static::getEntityTypeId($plugin_id);
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('entity.manager')->getStorage($entity_type_id),
|
||||
array_keys($container->get('entity.manager')->getBundleInfo($entity_type_id)),
|
||||
$container->get('plugin.manager.field.field_type')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
$this->dependencies = parent::calculateDependencies();
|
||||
// Add a dependency on the module that provides the field type using the
|
||||
// source plugin configuration.
|
||||
$source_configuration = $this->migration->get('source');
|
||||
if (isset($source_configuration['constants']['type'])) {
|
||||
$field_type = $this->fieldTypePluginManager->getDefinition($source_configuration['constants']['type']);
|
||||
$this->addDependency('module', $field_type['provider']);
|
||||
}
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static function getEntityTypeId($plugin_id) {
|
||||
return 'field_storage_config';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\load;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateLoadInterface;
|
||||
use Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface;
|
||||
|
||||
/**
|
||||
* Base class for entity load plugins.
|
||||
*
|
||||
* @ingroup migration
|
||||
*
|
||||
* @PluginID("drupal_entity")
|
||||
*/
|
||||
class LoadEntity extends PluginBase implements MigrateLoadInterface {
|
||||
|
||||
/**
|
||||
* The list of bundles being loaded.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $bundles;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->migration = $migration;
|
||||
$source_plugin = $this->migration->getSourcePlugin();
|
||||
if (!$source_plugin instanceof SourceEntityInterface) {
|
||||
throw new MigrateException('Migrations with a load plugin using LoadEntity should have an entity as source.');
|
||||
}
|
||||
if ($source_plugin->bundleMigrationRequired() && empty($configuration['bundle_migration'])) {
|
||||
throw new MigrateException(SafeMarkup::format('Source plugin @plugin requires the bundle_migration key to be set.', array('@plugin' => $source_plugin->getPluginId())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(EntityStorageInterface $storage, $sub_id) {
|
||||
$entities = $this->loadMultiple($storage, array($sub_id));
|
||||
return isset($entities[$sub_id]) ? $entities[$sub_id] : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL) {
|
||||
if (isset($this->configuration['bundle_migration'])) {
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
|
||||
$bundle_migration = $storage->load($this->configuration['bundle_migration']);
|
||||
$source_id = array_keys($bundle_migration->getSourcePlugin()->getIds())[0];
|
||||
$this->bundles = array();
|
||||
foreach ($bundle_migration->getSourcePlugin()->getIterator() as $row) {
|
||||
$this->bundles[] = $row[$source_id];
|
||||
}
|
||||
}
|
||||
else {
|
||||
// This entity type has no bundles ('user', 'feed', etc).
|
||||
$this->bundles = array($this->migration->getSourcePlugin()->entityTypeId());
|
||||
}
|
||||
$sub_ids_to_load = isset($sub_ids) ? array_intersect($this->bundles, $sub_ids) : $this->bundles;
|
||||
$migrations = array();
|
||||
foreach ($sub_ids_to_load as $id) {
|
||||
$values = $this->migration->toArray();
|
||||
$values['id'] = $this->migration->id() . ':' . $id;
|
||||
$values['source']['bundle'] = $id;
|
||||
/** @var \Drupal\migrate_drupal\Entity\MigrationInterface $migration */
|
||||
$migration = $storage->create($values);
|
||||
try {
|
||||
$migration->getSourcePlugin()->checkRequirements();
|
||||
$source_plugin = $migration->getSourcePlugin();
|
||||
|
||||
if ($source_plugin instanceof CckFieldMigrateSourceInterface) {
|
||||
foreach ($source_plugin->fieldData() as $field_name => $data) {
|
||||
switch ($data['type']) {
|
||||
case 'filefield':
|
||||
$this->processFileField($field_name, $data, $migration);
|
||||
break;
|
||||
case 'text':
|
||||
$this->processTextField($field_name, $data, $migration);
|
||||
break;
|
||||
default:
|
||||
$migration->setProcessOfProperty($field_name, $field_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$fields = array_keys($migration->getSourcePlugin()->fields());
|
||||
$migration->setProcess($migration->getProcess() + array_combine($fields, $fields));
|
||||
}
|
||||
$migrations[$migration->id()] = $migration;
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulate text fields with any per field type processing.
|
||||
*
|
||||
* @param string $field_name
|
||||
* The field we're processing.
|
||||
* @param array $field_data
|
||||
* The an array of field type data from the source.
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
protected function processTextField($field_name, $field_data, MigrationInterface $migration) {
|
||||
// The data is stored differently depending on whether we're using
|
||||
// db storage.
|
||||
$value_key = $field_data['db_storage'] ? $field_name : "$field_name/value";
|
||||
$format_key = $field_data['db_storage'] ? $field_name . '_format' : "$field_name/format" ;
|
||||
|
||||
$migration->setProcessOfProperty("$field_name/value", $value_key);
|
||||
|
||||
// See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(),
|
||||
// signature_format for an example of the YAML that represents this
|
||||
// process array.
|
||||
$process = [
|
||||
[
|
||||
'plugin' => 'static_map',
|
||||
'bypass' => TRUE,
|
||||
'source' => $format_key,
|
||||
'map' => [0 => NULL]
|
||||
],
|
||||
[
|
||||
'plugin' => 'skip_on_empty',
|
||||
'method' => 'process',
|
||||
],
|
||||
[
|
||||
'plugin' => 'migration',
|
||||
'migration' => 'd6_filter_format',
|
||||
'source' => $format_key,
|
||||
],
|
||||
];
|
||||
$migration->mergeProcessOfProperty("$field_name/format", $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulate file fields with any per field type processing.
|
||||
*
|
||||
* @param string $field_name
|
||||
* The field we're processing.
|
||||
* @param array $field_data
|
||||
* The an array of field type data from the source.
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
protected function processFileField($field_name, $field_data, MigrationInterface $migration) {
|
||||
$process = [
|
||||
'plugin' => 'd6_cck_file',
|
||||
'source' => [
|
||||
$field_name,
|
||||
$field_name . '_list',
|
||||
$field_name . '_data',
|
||||
],
|
||||
];
|
||||
$migration->mergeProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\load\d6\LoadTermNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\load\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\migrate\MigrateMessage;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\load\LoadEntity;
|
||||
|
||||
/**
|
||||
* @PluginID("d6_term_node")
|
||||
*/
|
||||
class LoadTermNode extends LoadEntity {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration) {
|
||||
$configuration['bundle_migration'] = 'd6_taxonomy_vocabulary';
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL) {
|
||||
/** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
|
||||
$bundle_migration = $storage->load('d6_taxonomy_vocabulary');
|
||||
$migrate_executable = new MigrateExecutable($bundle_migration, new MigrateMessage());
|
||||
$process = array_intersect_key($bundle_migration->get('process'), $bundle_migration->getDestinationPlugin()->getIds());
|
||||
$migrations = array();
|
||||
$vid_map = array();
|
||||
foreach ($bundle_migration->getIdMap() as $key => $value) {
|
||||
$old_vid = unserialize($key)['sourceid1'];
|
||||
$new_vid = $value['destid1'];
|
||||
$vid_map[$old_vid] = $new_vid;
|
||||
}
|
||||
foreach ($bundle_migration->getSourcePlugin()->getIterator() as $source_row) {
|
||||
$row = new Row($source_row, $source_row);
|
||||
$migrate_executable->processRow($row, $process);
|
||||
$old_vid = $source_row['vid'];
|
||||
$new_vid = $row->getDestinationProperty('vid');
|
||||
$vid_map[$old_vid] = $new_vid;
|
||||
}
|
||||
foreach ($vid_map as $old_vid => $new_vid) {
|
||||
$values = $this->migration->toArray();
|
||||
$migration_id = $this->migration->id() . ':' . $old_vid;
|
||||
$values['id'] = $migration_id;
|
||||
$values['source']['vid'] = $old_vid;
|
||||
$values['process'][$new_vid] = 'tid';
|
||||
$migrations[$migration_id] = $storage->create($values);;
|
||||
}
|
||||
|
||||
return $migrations;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\BlockPluginId.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\MigrateSkipRowException;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_plugin_id"
|
||||
* )
|
||||
*/
|
||||
class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* @var \Drupal\migrate\Plugin\MigratePluginManager
|
||||
*/
|
||||
protected $processPluginManager;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Entity\EntityStorageInterface
|
||||
*/
|
||||
protected $blockContentStorage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, MigratePluginManager $process_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->blockContentStorage = $storage;
|
||||
$this->migration = $migration;
|
||||
$this->processPluginManager = $process_plugin_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
$entity_manager = $container->get('entity.manager');
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$entity_manager->getDefinition('block_content') ? $entity_manager->getStorage('block_content') : NULL,
|
||||
$container->get('plugin.manager.migrate.process')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block plugin id.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if (is_array($value)) {
|
||||
list($module, $delta) = $value;
|
||||
switch ($module) {
|
||||
case 'aggregator':
|
||||
list($type, $id) = explode('-', $delta);
|
||||
if ($type == 'category') {
|
||||
// @TODO skip row.
|
||||
// throw new MigrateSkipRowException();
|
||||
}
|
||||
$value = 'aggregator_feed_block';
|
||||
break;
|
||||
case 'menu':
|
||||
$value = "system_menu_block:$delta";
|
||||
break;
|
||||
case 'block':
|
||||
if ($this->blockContentStorage) {
|
||||
$block_ids = $this->processPluginManager
|
||||
->createInstance('migration', array('migration' => 'd6_custom_block'), $this->migration)
|
||||
->transform($delta, $migrate_executable, $row, $destination_property);
|
||||
$value = 'block_content:' . $this->blockContentStorage->load($block_ids[0])->uuid();
|
||||
}
|
||||
else {
|
||||
throw new MigrateSkipRowException();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new MigrateSkipRowException();
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\BlockRegion.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_region"
|
||||
* )
|
||||
*/
|
||||
class BlockRegion extends ProcessPluginBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the destination block region, based on the source region and theme as
|
||||
* well as the current destination default theme.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($region, $source_theme, $destination_theme) = $value;
|
||||
|
||||
// Theme is the same on both source and destination, we will assume they
|
||||
// have the same regions.
|
||||
if (strtolower($source_theme) == strtolower($destination_theme)) {
|
||||
return $region;
|
||||
}
|
||||
|
||||
// If the source and destination theme are different, try to use the
|
||||
// mappings defined in the configuration.
|
||||
$region_map = $this->configuration['region_map'];
|
||||
if (isset($region_map[$region])) {
|
||||
return $region_map[$region];
|
||||
}
|
||||
|
||||
// Oh well, we tried. Put the block in the main content region.
|
||||
return 'content';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\BlockSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_settings"
|
||||
* )
|
||||
*/
|
||||
class BlockSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block configuration.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($plugin, $delta, $old_settings) = $value;
|
||||
$settings = array();
|
||||
switch ($plugin) {
|
||||
case 'aggregator_feed_block':
|
||||
list(, $id) = explode('-', $delta);
|
||||
$settings['block_count'] = $old_settings['aggregator']['item_count'];
|
||||
$settings['feed'] = $id;
|
||||
break;
|
||||
case 'book_navigation':
|
||||
$settings['block_mode'] = $old_settings['book']['block_mode'];
|
||||
break;
|
||||
case 'forum_active_block':
|
||||
case 'forum_new_block':
|
||||
$settings['block_count'] = $old_settings['forum']['block_num'];
|
||||
break;
|
||||
case 'statistics_popular_block':
|
||||
$settings['top_day_num'] = $old_settings['statistics']['statistics_block_top_day_num'];
|
||||
$settings['top_all_num'] = $old_settings['statistics']['statistics_block_top_all_num'];
|
||||
$settings['top_last_num'] = $old_settings['statistics']['statistics_block_top_last_num'];
|
||||
break;
|
||||
case 'views_block:who_s_new-block_1':
|
||||
$settings['items_per_page'] = $old_settings['user']['block_whois_new_count'];
|
||||
break;
|
||||
case 'views_block:who_s_online-who_s_online_block':
|
||||
$settings['items_per_page'] = $old_settings['user']['max_list_count'];
|
||||
break;
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\BlockTheme.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_theme"
|
||||
* )
|
||||
*/
|
||||
class BlockTheme extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* Contains the configuration object factory.
|
||||
*
|
||||
* @var \Drupal\Core\Config\ConfigFactoryInterface
|
||||
*/
|
||||
protected $configFactory;
|
||||
|
||||
/**
|
||||
* Contains the system.theme configuration object.
|
||||
*
|
||||
* @var \Drupal\Core\Config\Config
|
||||
*/
|
||||
protected $themeConfig;
|
||||
|
||||
/**
|
||||
* Constructs a BlockTheme object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\migrate\Entity\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
* @param \Drupal\Core\Config\Config $theme_config
|
||||
* The system.theme configuration factory object.
|
||||
* @param array $themes
|
||||
* The list of themes available on the destination.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, Config $theme_config, array $themes) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->themeConfig = $theme_config;
|
||||
$this->themes = $themes;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('config.factory')->get('system.theme'),
|
||||
$container->get('theme_handler')->listInfo()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block theme, based on the current default theme.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($theme, $d6_default_theme, $d6_admin_theme) = $value;
|
||||
|
||||
// If the source theme exists on the destination, we're good.
|
||||
if (isset($this->themes[$theme])) {
|
||||
return $theme;
|
||||
}
|
||||
|
||||
// If the source block is assigned to a region in the source default theme,
|
||||
// then assign it to the destination default theme.
|
||||
if (strtolower($theme) == strtolower($d6_default_theme)) {
|
||||
return $this->themeConfig->get('default');
|
||||
}
|
||||
|
||||
// If the source block is assigned to a region in the source admin theme,
|
||||
// then assign it to the destination admin theme.
|
||||
if (strtolower($theme) == strtolower($d6_admin_theme)) {
|
||||
return $this->themeConfig->get('admin');
|
||||
}
|
||||
|
||||
// We couldn't map it to a D8 theme so just return the incoming theme.
|
||||
return $theme;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\BlockVisibility.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_block_visibility"
|
||||
* )
|
||||
*/
|
||||
class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration plugin.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*/
|
||||
protected $migrationPlugin;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
$this->migrationPlugin = $migration_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_role'), $migration)
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the block visibility settings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($pages, $roles, $old_visibility) = $value;
|
||||
$visibility = array();
|
||||
|
||||
if (!empty($pages)) {
|
||||
$visibility['request_path']['pages'] = $pages;
|
||||
$visibility['request_path']['id'] = 'request_path';
|
||||
$visibility['request_path']['negate'] = !$old_visibility;
|
||||
}
|
||||
|
||||
if (!empty($roles)) {
|
||||
foreach ($roles as $key => $role_id) {
|
||||
$new_role = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property);
|
||||
$visibility['user_role']['roles'][$new_role] = $new_role;
|
||||
}
|
||||
$visibility['user_role']['id'] = 'user_role';
|
||||
$visibility['user_role']['context_mapping']['user'] = 'user.current_user';
|
||||
}
|
||||
return $visibility;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\CckFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\migrate\process\Route;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_cck_file"
|
||||
* )
|
||||
*/
|
||||
class CckFile extends Route implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($fid, $list, $data) = $value;
|
||||
|
||||
// If $fid is still an array at this point, that's because we have a file
|
||||
// attachment as per D6 core. If not, then we have a filefield from contrib.
|
||||
if (is_array($fid)) {
|
||||
$list = $fid['list'];
|
||||
$fid = $fid['fid'];
|
||||
}
|
||||
else {
|
||||
$options = unserialize($data);
|
||||
}
|
||||
|
||||
$file = [
|
||||
'target_id' => $fid,
|
||||
'display' => isset($list) ? $list : 0,
|
||||
'description' => isset($options['description']) ? $options['description'] : '',
|
||||
];
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\CckLink.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\migrate\process\Route;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_cck_link"
|
||||
* )
|
||||
*/
|
||||
class CckLink extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($url, $title, $attributes) = $value;
|
||||
|
||||
// Drupal 6 link attributes are double serialized.
|
||||
$attributes = unserialize(unserialize($attributes));
|
||||
|
||||
// Massage the values into the correct form for the link.
|
||||
$route['uri'] = $url;
|
||||
$route['options']['attributes'] = $attributes;
|
||||
$route['title'] = $title;
|
||||
return $route;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldFormatterSettingsDefaults.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Set the default field settings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_formatter_settings_defaults"
|
||||
* )
|
||||
*/
|
||||
class FieldFormatterSettingsDefaults extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set field formatter settings when the map didn't map: for date
|
||||
* formatters, the fallback format, for everything else, empty array.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
// If the 1 index is set then the map missed.
|
||||
if (isset($value[1])) {
|
||||
$module = $row->getSourceProperty('module');
|
||||
if ($module === 'date') {
|
||||
$value = array('format_type' => 'fallback');
|
||||
}
|
||||
elseif ($module === 'number') {
|
||||
// We have to do the lookup here in the process plugin because for
|
||||
// number we need to calculated the settings based on the type not just
|
||||
// the module which works well for other field types.
|
||||
return $this->numberSettings($row->getDestinationProperty('options/type'), $value[1]);
|
||||
}
|
||||
else {
|
||||
$value = array();
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* The field type.
|
||||
* @param $format
|
||||
* The format selected for the field on the display.
|
||||
*
|
||||
* @return array
|
||||
* The correct default settings.
|
||||
*
|
||||
* @throws \Drupal\migrate\MigrateException
|
||||
*/
|
||||
protected function numberSettings($type, $format) {
|
||||
$map = [
|
||||
'number_decimal' => [
|
||||
'us_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'us_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'us_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => '.',
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_0' => [
|
||||
'scale' => 0,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_1' => [
|
||||
'scale' => 1,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_2' => [
|
||||
'scale' => 2,
|
||||
'decimal_separator' => ',',
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
],
|
||||
'number_integer' => [
|
||||
'us_0' => [
|
||||
'thousand_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'be_0' => [
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
'fr_0' => [
|
||||
'thousand_separator' => ' ',
|
||||
'prefix_suffix' => TRUE,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return isset($map[$type][$format]) ? $map[$type][$format] : [];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldIdGenerator.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Generate the file name for field config entities.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_id_generator"
|
||||
* )
|
||||
*/
|
||||
class FieldIdGenerator extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
return $value[0] . "." . $value[1];
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldInstanceDefaults.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_field_instance_defaults"
|
||||
* )
|
||||
*/
|
||||
class FieldInstanceDefaults extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the field instance defaults.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($widget_type, $widget_settings) = $value;
|
||||
$default = array();
|
||||
|
||||
switch ($widget_type) {
|
||||
case 'text_textfield':
|
||||
case 'number':
|
||||
case 'phone_textfield':
|
||||
if (!empty($widget_settings['default_value'][0]['value'])) {
|
||||
$default['value'] = $widget_settings['default_value'][0]['value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'imagefield_widget':
|
||||
// @todo, load the image and populate the defaults.
|
||||
// $default['default_image'] = $widget_settings['default_image'];
|
||||
break;
|
||||
|
||||
case 'date_select':
|
||||
if (!empty($widget_settings['default_value'])) {
|
||||
$default['default_date_type'] = 'relative';
|
||||
$default['default_date'] = $widget_settings['default_value'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'email_textfield':
|
||||
if (!empty($widget_settings['default_value'][0]['email'])) {
|
||||
$default['value'] = $widget_settings['default_value'][0]['email'];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
if (!empty($widget_settings['default_value'][0]['url'])) {
|
||||
$default['title'] = $widget_settings['default_value'][0]['title'];
|
||||
$default['url'] = $widget_settings['default_value'][0]['url'];
|
||||
$default['options'] = ['attributes' => []];
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!empty($default)) {
|
||||
$default = array($default);
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldInstanceSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_field_field_settings"
|
||||
* )
|
||||
*/
|
||||
class FieldInstanceSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the field instance defaults.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($widget_type, $widget_settings, $field_settings) = $value;
|
||||
$settings = array();
|
||||
switch ($widget_type) {
|
||||
case 'number':
|
||||
$settings['min'] = $field_settings['min'];
|
||||
$settings['max'] = $field_settings['max'];
|
||||
$settings['prefix'] = $field_settings['prefix'];
|
||||
$settings['suffix'] = $field_settings['suffix'];
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
// $settings['url'] = $widget_settings['default_value'][0]['url'];
|
||||
// D6 has optional, required, value and none. D8 only has disabled (0)
|
||||
// optional (1) and required (2).
|
||||
$map = array('disabled' => 0, 'optional' => 1, 'required' => 2);
|
||||
$settings['title'] = $map[$field_settings['title']];
|
||||
break;
|
||||
|
||||
case 'filefield_widget':
|
||||
$settings['file_extensions'] = $widget_settings['file_extensions'];
|
||||
$settings['file_directory'] = $widget_settings['file_path'];
|
||||
$settings['description_field'] = $field_settings['description_field'];
|
||||
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file']);
|
||||
break;
|
||||
|
||||
case 'imagefield_widget':
|
||||
$settings['file_extensions'] = $widget_settings['file_extensions'];
|
||||
$settings['file_directory'] = 'public://';
|
||||
$settings['max_filesize'] = $this->convertSizeUnit($widget_settings['max_filesize_per_file']);
|
||||
$settings['alt_field'] = $widget_settings['alt'];
|
||||
$settings['alt_field_required'] = $widget_settings['custom_alt'];
|
||||
$settings['title_field'] = $widget_settings['title'];
|
||||
$settings['title_field_required'] = $widget_settings['custom_title'];
|
||||
$settings['max_resolution'] = $widget_settings['max_resolution'];
|
||||
$settings['min_resolution'] = $widget_settings['min_resolution'];
|
||||
break;
|
||||
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert file size strings into their D8 format.
|
||||
*
|
||||
* D6 stores file size using a "K" for kilobytes and "M" for megabytes where
|
||||
* as D8 uses "KB" and "MB" respectively.
|
||||
*
|
||||
* @param string $size_string
|
||||
* The size string, eg 10M
|
||||
*
|
||||
* @return string
|
||||
* The D8 version of the size string.
|
||||
*/
|
||||
protected function convertSizeUnit($size_string) {
|
||||
$size_unit = substr($size_string, strlen($size_string) - 1);
|
||||
if ($size_unit == "M" || $size_unit == "K") {
|
||||
return $size_string . "B";
|
||||
}
|
||||
return $size_string;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldInstanceWidgetSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Get the field instance widget settings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_instance_widget_settings"
|
||||
* )
|
||||
*/
|
||||
class FieldInstanceWidgetSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Get the field instance default/mapped widget settings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($widget_type, $widget_settings) = $value;
|
||||
return $this->getSettings($widget_type, $widget_settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the default D8 and specified D6 settings for a widget type.
|
||||
*
|
||||
* @param string $widget_type
|
||||
* The widget type.
|
||||
* @param array $widget_settings
|
||||
* The widget settings from D6 for this widget.
|
||||
*
|
||||
* @return array
|
||||
* A valid array of settings.
|
||||
*/
|
||||
public function getSettings($widget_type, $widget_settings) {
|
||||
$progress = isset($widget_settings['progress_indicator']) ? $widget_settings['progress_indicator'] : 'throbber';
|
||||
$size = isset($widget_settings['size']) ? $widget_settings['size'] : 60;
|
||||
$rows = isset($widget_settings['rows']) ? $widget_settings['rows'] : 5;
|
||||
|
||||
$settings = array(
|
||||
'text_textfield' => array(
|
||||
'size' => $size,
|
||||
'placeholder' => '',
|
||||
),
|
||||
'text_textarea' => array(
|
||||
'rows' => $rows,
|
||||
'placeholder' => '',
|
||||
),
|
||||
'number' => array(
|
||||
'placeholder' => '',
|
||||
),
|
||||
'email_textfield' => array(
|
||||
'placeholder' => '',
|
||||
),
|
||||
'link' => array(
|
||||
'placeholder_url' => '',
|
||||
'placeholder_title' => '',
|
||||
),
|
||||
'filefield_widget' => array(
|
||||
'progress_indicator' => $progress,
|
||||
),
|
||||
'imagefield_widget' => array(
|
||||
'progress_indicator' => $progress,
|
||||
'preview_image_style' => 'thumbnail',
|
||||
),
|
||||
'optionwidgets_onoff' => array(
|
||||
'display_label' => FALSE,
|
||||
),
|
||||
'phone_textfield' => array(
|
||||
'placeholder' => '',
|
||||
),
|
||||
);
|
||||
|
||||
return isset($settings[$widget_type]) ? $settings[$widget_type] : array();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Get the field settings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_settings"
|
||||
* )
|
||||
*/
|
||||
class FieldSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Get the field default/mapped settings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($field_type, $global_settings, $widget_settings) = $value;
|
||||
return $this->getSettings($field_type, $global_settings, $widget_settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge the default D8 and specified D6 settings.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type.
|
||||
* @param array $global_settings
|
||||
* The field settings.
|
||||
* @param array $widget_settings
|
||||
* The widget settings needed for some settings.
|
||||
*
|
||||
* @return array
|
||||
* A valid array of settings.
|
||||
*/
|
||||
public function getSettings($field_type, $global_settings, $widget_settings) {
|
||||
$max_length = isset($global_settings['max_length']) ? $global_settings['max_length'] : '';
|
||||
$max_length = empty($max_length) ? 255 : $max_length;
|
||||
if (isset($global_settings['allowed_values'])) {
|
||||
$list = explode("\n", $global_settings['allowed_values']);
|
||||
$list = array_map('trim', $list);
|
||||
$list = array_filter($list, 'strlen');
|
||||
switch ($field_type) {
|
||||
case 'list_string':
|
||||
case 'list_integer':
|
||||
case 'list_float':
|
||||
foreach ($list as $value) {
|
||||
$value = explode("|", $value);
|
||||
$allowed_values[$value[0]] = isset($value[1]) ? $value[1] : $value[0];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$allowed_values = $list;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$allowed_values = '';
|
||||
}
|
||||
|
||||
$settings = array(
|
||||
'text' => array(
|
||||
'max_length' => $max_length,
|
||||
),
|
||||
'datetime' => array('datetime_type' => 'datetime'),
|
||||
'list_string' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
'list_integer' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
'list_float' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
'boolean' => array(
|
||||
'allowed_values' => $allowed_values,
|
||||
),
|
||||
);
|
||||
|
||||
return isset($settings[$field_type]) ? $settings[$field_type] : array();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FieldTypeDefaults.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Gives us a change to set per field defaults.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "field_type_defaults"
|
||||
* )
|
||||
*/
|
||||
class FieldTypeDefaults extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if (is_array($value)) {
|
||||
if ($row->getSourceProperty('module') == 'date') {
|
||||
$value = 'datetime_default';
|
||||
}
|
||||
else {
|
||||
throw new MigrateException(sprintf('Failed to lookup %s in the static map.', var_export($value, TRUE)));
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FileUri.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Process the file url into a D8 compatible URL.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "file_uri"
|
||||
* )
|
||||
*/
|
||||
class FileUri extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
|
||||
list($filepath, $file_directory_path, $temp_directory_path, $is_public) = $value;
|
||||
|
||||
// Specific handling using $temp_directory_path for temporary files.
|
||||
if (substr($filepath, 0, strlen($temp_directory_path)) === $temp_directory_path) {
|
||||
$uri = preg_replace('/^' . preg_quote($temp_directory_path, '/') . '/', '', $filepath);
|
||||
return "temporary://$uri";
|
||||
}
|
||||
|
||||
// Strip the files path from the uri instead of using basename
|
||||
// so any additional folders in the path are preserved.
|
||||
$uri = preg_replace('/^' . preg_quote($file_directory_path, '/') . '/', '', $filepath);
|
||||
|
||||
return $is_public ? "public://$uri" : "private://$uri";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\FilterFormatPermission.
|
||||
*/
|
||||
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Migrate filter format serial to string id in permission name.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "filter_format_permission",
|
||||
* handle_multiples = TRUE
|
||||
* )
|
||||
*/
|
||||
class FilterFormatPermission extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration plugin.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*/
|
||||
protected $migrationPlugin;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
$this->migrationPlugin = $migration_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_filter_format'), $migration)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Migrate filter format serial to string id in permission name.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$rid = $row->getSourceProperty('rid');
|
||||
if ($formats = $row->getSourceProperty("filter_permissions:$rid")) {
|
||||
foreach ($formats as $format) {
|
||||
$new_id = $this->migrationPlugin->transform($format, $migrate_executable, $row, $destination_property);
|
||||
if ($new_id) {
|
||||
$value[] = 'use text format ' . $new_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\InternalUri.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Process a path into an 'internal:' URI.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "internal_uri"
|
||||
* )
|
||||
*/
|
||||
class InternalUri extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
list($path) = $value;
|
||||
|
||||
if (parse_url($path, PHP_URL_SCHEME) === NULL) {
|
||||
return 'internal:/' . $path;
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\NodeUpdate7008.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Split the 'administer nodes' permission from 'access content overview'.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "node_update_7008"
|
||||
* )
|
||||
*/
|
||||
class NodeUpdate7008 extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Split the 'administer nodes' permission from 'access content overview'.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
if ($value === 'administer nodes') {
|
||||
return array($value, 'access content overview');
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\ProfileFieldSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_profile_field_settings"
|
||||
* )
|
||||
*/
|
||||
class ProfileFieldSettings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Set the profile field settings configuration.
|
||||
*/
|
||||
public function transform($type, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$settings = array();
|
||||
switch ($type) {
|
||||
case 'date':
|
||||
$settings['datetime_type'] = 'date';
|
||||
break;
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\SearchConfigurationRankings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Generate configuration rankings.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_search_configuration_rankings"
|
||||
* )
|
||||
*/
|
||||
class SearchConfigurationRankings extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Generate the configuration rankings.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$return = array();
|
||||
foreach ($row->getSource() as $name => $rank) {
|
||||
if (substr($name, 0, 10) == 'node_rank_' && $rank) {
|
||||
$return[substr($name, 10)] = $rank;
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\SystemUpdate7000.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Rename blog and forum permissions to be consistent with other content types.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "system_update_7000"
|
||||
* )
|
||||
*/
|
||||
class SystemUpdate7000 extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Rename blog and forum permissions to be consistent with other content types.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$value = preg_replace('/(?<=^|,\ )create\ blog\ entries(?=,|$)/', 'create blog content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )edit\ own\ blog\ entries(?=,|$)/', 'edit own blog content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )edit\ any\ blog\ entry(?=,|$)/', 'edit any blog content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )delete\ own\ blog\ entries(?=,|$)/', 'delete own blog content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )delete\ any\ blog\ entry(?=,|$)/', 'delete any blog content', $value);
|
||||
|
||||
$value = preg_replace('/(?<=^|,\ )create\ forum\ topics(?=,|$)/', 'create forum content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )delete\ any\ forum\ topic(?=,|$)/', 'delete any forum content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )delete\ own\ forum\ topics(?=,|$)/', 'delete own forum content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )edit\ any\ forum\ topic(?=,|$)/', 'edit any forum content', $value);
|
||||
$value = preg_replace('/(?<=^|,\ )edit\ own\ forum\ topics(?=,|$)/', 'edit own forum content', $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserPicture.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\Plugin\MigrateProcessInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* The user picture process plugin.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "d6_user_picture"
|
||||
* )
|
||||
*/
|
||||
class UserPicture extends ProcessPluginBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The migration plugin.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrateProcessInterface
|
||||
*/
|
||||
protected $migrationPlugin;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
$this->migration = $migration;
|
||||
$this->migrationPlugin = $migration_plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('plugin.manager.migrate.process')->createInstance('migration', array('migration' => 'd6_user_picture_file'), $migration)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
return $row->getSourceProperty('picture') ? $this->migrationPlugin->transform($value, $migrate_executable, $row, $destination_property) : NULL;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserUpdate7002.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Converts user time zones from time zone offsets to time zone names.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "user_update_7002"
|
||||
* )
|
||||
*/
|
||||
class UserUpdate7002 extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* System timezones.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $timezones;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
if (!isset(static::$timezones)) {
|
||||
static::$timezones = system_time_zones();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$timezone = NULL;
|
||||
|
||||
if ($row->hasSourceProperty('timezone_name')) {
|
||||
if (isset(static::$timezones[$row->getSourceProperty('timezone_name')])) {
|
||||
$timezone = $row->getSourceProperty('timezone_name');
|
||||
}
|
||||
}
|
||||
if (!$timezone && $row->hasSourceProperty('event_timezone')) {
|
||||
if (isset(static::$timezones[$row->getSourceProperty('event_timezone')])) {
|
||||
$timezone = $row->getSourceProperty('event_timezone');
|
||||
}
|
||||
}
|
||||
|
||||
return $timezone;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\process\d6\UserUpdate8002.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\process\d6;
|
||||
use Drupal\migrate\MigrateExecutableInterface;
|
||||
use Drupal\migrate\ProcessPluginBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Keep the predefined roles for rid 1 and 2.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "user_update_8002"
|
||||
* )
|
||||
*/
|
||||
class UserUpdate8002 extends ProcessPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Keep the predefined roles for rid 1 and 2.
|
||||
*/
|
||||
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
|
||||
$rid = $row->getSourceProperty('rid');
|
||||
$map = array(
|
||||
1 => 'anonymous',
|
||||
2 => 'authenticated',
|
||||
);
|
||||
return isset($map[$rid]) ? $map[$rid] : $value;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,182 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Component\Plugin\DependentPluginInterface;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Entity\DependencyTrait;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\migrate\source\SqlBase;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* A base source class for Drupal migrate sources.
|
||||
*
|
||||
* Mainly to let children retrieve information from the origin system in an
|
||||
* easier way.
|
||||
*/
|
||||
abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginInterface, RequirementsInterface, DependentPluginInterface {
|
||||
|
||||
use DependencyTrait;
|
||||
|
||||
/**
|
||||
* The contents of the system table.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $systemData;
|
||||
|
||||
/**
|
||||
* If the source provider is missing.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $requirements = TRUE;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->entityManager = $entity_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves all system data information from origin system.
|
||||
*
|
||||
* @return array
|
||||
* List of system table information keyed by type and name.
|
||||
*/
|
||||
public function getSystemData() {
|
||||
if (!isset($this->systemData)) {
|
||||
$this->systemData = array();
|
||||
try {
|
||||
$results = $this->select('system', 's')
|
||||
->fields('s')
|
||||
->execute();
|
||||
foreach ($results as $result) {
|
||||
$this->systemData[$result['type']][$result['name']] = $result;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
// The table might not exist for example in tests.
|
||||
}
|
||||
}
|
||||
return $this->systemData;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('entity.manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function checkRequirements() {
|
||||
if ($this->pluginDefinition['requirements_met'] === TRUE) {
|
||||
if (isset($this->pluginDefinition['source_provider'])) {
|
||||
if ($this->moduleExists($this->pluginDefinition['source_provider'])) {
|
||||
if (isset($this->pluginDefinition['minimum_schema_version']) && !$this->getModuleSchemaVersion($this->pluginDefinition['source_provider']) < $this->pluginDefinition['minimum_schema_version']) {
|
||||
throw new RequirementsException(SafeMarkup::format('Required minimum schema version @minimum_schema_version', ['@minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]), ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RequirementsException(SafeMarkup::format('Missing source provider @provider', ['@provider' => $this->pluginDefinition['source_provider']]), ['source_provider' => $this->pluginDefinition['source_provider']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a module schema_version value in the source installation.
|
||||
*
|
||||
* @param string $module
|
||||
* Name of module.
|
||||
*
|
||||
* @return mixed
|
||||
* The current module schema version on the origin system table or FALSE if
|
||||
* not found.
|
||||
*/
|
||||
protected function getModuleSchemaVersion($module) {
|
||||
$system_data = $this->getSystemData();
|
||||
return isset($system_data['module'][$module]['schema_version']) ? $system_data['module'][$module]['schema_version'] : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a given module is enabled in the source installation.
|
||||
*
|
||||
* @param string $module
|
||||
* Name of module to check.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if module is enabled on the origin system, FALSE if not.
|
||||
*/
|
||||
protected function moduleExists($module) {
|
||||
$system_data = $this->getSystemData();
|
||||
return !empty($system_data['module'][$module]['status']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a variable from a Drupal database.
|
||||
*
|
||||
* @param $name
|
||||
* Name of the variable.
|
||||
* @param $default
|
||||
* The default value.
|
||||
* @return mixed
|
||||
*/
|
||||
protected function variableGet($name, $default) {
|
||||
try {
|
||||
$result = $this->select('variable', 'v')
|
||||
->fields('v', array('value'))
|
||||
->condition('name', $name)
|
||||
->execute()
|
||||
->fetchField();
|
||||
}
|
||||
// The table might not exist.
|
||||
catch (\Exception $e) {
|
||||
$result = FALSE;
|
||||
}
|
||||
return $result !== FALSE ? unserialize($result) : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
// Generic handling for Drupal source plugin constants.
|
||||
if (isset($this->configuration['constants']['entity_type'])) {
|
||||
$this->addDependency('module', $this->entityManager->getDefinition($this->configuration['constants']['entity_type'])->getProvider());
|
||||
}
|
||||
if (isset($this->configuration['constants']['module'])) {
|
||||
$this->addDependency('module', $this->configuration['constants']['module']);
|
||||
}
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\EmptySource.
|
||||
*/
|
||||
|
||||
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\Plugin\migrate\source\EmptySource as BaseEmptySource;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Source returning an empty row with Drupal specific config dependencies.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "md_empty"
|
||||
* )
|
||||
*/
|
||||
class EmptySource extends BaseEmptySource implements ContainerFactoryPluginInterface, DependentPluginInterface {
|
||||
|
||||
use DependencyTrait;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->entityManager = $entity_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('entity.manager')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
// The empty source plugin supports the entity_type constant.
|
||||
if (isset($this->configuration['constants']['entity_type'])) {
|
||||
$this->addDependency('module', $this->entityManager->getDefinition($this->configuration['constants']['entity_type'])->getProvider());
|
||||
}
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\Variable.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
|
||||
/**
|
||||
* Drupal variable source from database.
|
||||
*
|
||||
* This source class always returns a single row and as such is not a good
|
||||
* example for any normal source class returning multiple rows.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "variable"
|
||||
* )
|
||||
*/
|
||||
class Variable extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The variable names to fetch.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $variables;
|
||||
|
||||
/**
|
||||
* {@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);
|
||||
$this->variables = $this->configuration['variables'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
return new \ArrayIterator(array($this->values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the values of the variables specified in the plugin configuration.
|
||||
*
|
||||
* @return array
|
||||
* An associative array where the keys are the variables specified in the
|
||||
* plugin configuration and the values are the values found in the source.
|
||||
* Only those values are returned that are actually in the database.
|
||||
*/
|
||||
protected function values() {
|
||||
return array_map('unserialize', $this->prepareQuery()->execute()->fetchAllKeyed());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return intval($this->query()->countQuery()->execute()->fetchField() > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array_combine($this->variables, $this->variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->getDatabase()
|
||||
->select('variable', 'v')
|
||||
->fields('v', array('name', 'value'))
|
||||
->condition('name', $this->variables, 'IN');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Multiple variables source from database.
|
||||
*
|
||||
* Unlike the variable source plugin, this one returns one row per
|
||||
* variable.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "variable_multirow"
|
||||
* )
|
||||
*/
|
||||
class VariableMultiRow extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('variable', 'v')
|
||||
->fields('v', array('name', 'value'))
|
||||
// Cast scalars to array so we can consistently use an IN condition.
|
||||
->condition('name', (array) $this->configuration['variables'], 'IN');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'name' => $this->t('Name'),
|
||||
'value' => $this->t('Value'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
if ($value = $row->getSourceProperty('value')) {
|
||||
$row->setSourceProperty('value', unserialize($value));
|
||||
}
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Action.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 action source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_action"
|
||||
* )
|
||||
*/
|
||||
class Action extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('actions', 'a')
|
||||
->fields('a', array(
|
||||
'aid',
|
||||
'type',
|
||||
'callback',
|
||||
'parameters',
|
||||
'description',
|
||||
)
|
||||
);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'aid' => $this->t('Action ID'),
|
||||
'type' => $this->t('Module'),
|
||||
'callback' => $this->t('Callback function'),
|
||||
'parameters' => $this->t('Action configuration'),
|
||||
'description' => $this->t('Action description'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['aid']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\AggregatorFeed.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 feed source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_aggregator_feed",
|
||||
* source_provider = "aggregator"
|
||||
* )
|
||||
*/
|
||||
class AggregatorFeed extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('aggregator_feed', 'af')
|
||||
->fields('af', array(
|
||||
'fid',
|
||||
'title',
|
||||
'url',
|
||||
'refresh',
|
||||
'checked',
|
||||
'link',
|
||||
'description',
|
||||
'image',
|
||||
'etag',
|
||||
'modified',
|
||||
'block',
|
||||
));
|
||||
|
||||
$query->orderBy('fid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('The feed ID.'),
|
||||
'title' => $this->t('Title of the feed.'),
|
||||
'url' => $this->t('URL to the feed.'),
|
||||
'refresh' => $this->t('Refresh frequency in seconds.'),
|
||||
'checked' => $this->t('Last-checked unix timestamp.'),
|
||||
'link' => $this->t('Parent website of feed.'),
|
||||
'description' => $this->t('Parent website\'s description fo the feed.'),
|
||||
'image' => $this->t('An image representing the feed.'),
|
||||
'etag' => $this->t('Entity tag HTTP response header.'),
|
||||
'modified' => $this->t('When the feed was last modified.'),
|
||||
'block' => $this->t("Number of items to display in the feed's block."),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\AggregatorItem.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 aggregator item source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_aggregator_item",
|
||||
* source_provider = "aggregator"
|
||||
* )
|
||||
*/
|
||||
class AggregatorItem extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('aggregator_item', 'ai')
|
||||
->fields('ai', array('iid', 'fid', 'title', 'link', 'author',
|
||||
'description', 'timestamp', 'guid'))
|
||||
->orderBy('iid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'iid' => $this->t('Primary Key: Unique ID for feed item.'),
|
||||
'fid' => $this->t('The {aggregator_feed}.fid to which this item belongs.'),
|
||||
'title' => $this->t('Title of the feed item.'),
|
||||
'link' => $this->t('Link to the feed item.'),
|
||||
'author' => $this->t('Author of the feed item.'),
|
||||
'description' => $this->t('Body of the feed item.'),
|
||||
'timestamp' => $this->t('Post date of feed item, as a Unix timestamp.'),
|
||||
'guid' => $this->t('Unique identifier for the feed item.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['iid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Block.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 block source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_block"
|
||||
* )
|
||||
*/
|
||||
class Block extends DrupalSqlBase {
|
||||
/**
|
||||
* The default theme name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $defaultTheme;
|
||||
|
||||
/**
|
||||
* The admin theme name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $adminTheme;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('blocks', 'b')
|
||||
->fields('b', array('bid', 'module', 'delta', 'theme', 'status', 'weight', 'region', 'visibility', 'pages', 'title', 'cache'))
|
||||
->orderBy('bid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$this->defaultTheme = $this->variableGet('theme_default', 'Garland');
|
||||
$this->adminTheme = $this->variableGet('admin_theme', null);
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'bid' => $this->t('The block numeric identifier.'),
|
||||
'module' => $this->t('The module providing the block.'),
|
||||
'delta' => $this->t('The block\'s delta.'),
|
||||
'theme' => $this->t('Which theme the block is placed in.'),
|
||||
'status' => $this->t('Whether or not the block is enabled.'),
|
||||
'weight' => $this->t('Weight of the block for ordering within regions.'),
|
||||
'region' => $this->t('Region the block is placed in.'),
|
||||
'visibility' => $this->t('Visibility expression.'),
|
||||
'pages' => $this->t('Pages list.'),
|
||||
'title' => $this->t('Block title.'),
|
||||
'cache' => $this->t('Cache rule.'),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('default_theme', $this->defaultTheme);
|
||||
$row->setSourceProperty('admin_theme', $this->adminTheme);
|
||||
$module = $row->getSourceProperty('module');
|
||||
$delta = $row->getSourceProperty('delta');
|
||||
$roles = $this->select('blocks_roles', 'br')
|
||||
->fields('br', array('rid'))
|
||||
->condition('module', $module)
|
||||
->condition('delta', $delta)
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('roles', $roles);
|
||||
$settings = array();
|
||||
// Contrib can use hook_migration_d6_block_prepare_row() to add similar
|
||||
// variables via $migration->getSource()->variableGet().
|
||||
switch ($module) {
|
||||
case 'aggregator':
|
||||
list($type, $id) = explode('-', $delta);
|
||||
if ($type == 'feed') {
|
||||
$item_count = $this->database->query('SELECT block FROM {aggregator_feed} WHERE fid = :fid', array(':fid' => $id))->fetchField();
|
||||
}
|
||||
else {
|
||||
$item_count = $this->database->query('SELECT block FROM {aggregator_category} WHERE cid = :cid', array(':cid' => $id))->fetchField();
|
||||
}
|
||||
$settings['aggregator']['item_count'] = $item_count;
|
||||
break;
|
||||
case 'book':
|
||||
$settings['book']['block_mode'] = $this->variableGet('book_block_mode', 'all pages');
|
||||
break;
|
||||
case 'forum':
|
||||
$settings['forum']['block_num'] = $this->variableGet('forum_block_num_'. $delta, 5);
|
||||
break;
|
||||
case 'statistics':
|
||||
foreach (array('statistics_block_top_day_num', 'statistics_block_top_all_num', 'statistics_block_top_last_num') as $name) {
|
||||
$settings['statistics'][$name] = $this->variableGet($name, 0);
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
switch ($delta) {
|
||||
case 2:
|
||||
$settings['user']['block_whois_new_count'] = $this->variableGet('user_block_whois_new_count', 5);
|
||||
break;
|
||||
case 3:
|
||||
$settings['user']['block_seconds_online'] = $this->variableGet('user_block_seconds_online', 900);
|
||||
$settings['user']['max_list_count'] = $this->variableGet('user_block_max_list_count', 10);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$row->setSourceProperty('settings', $settings);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['module']['type'] = 'string';
|
||||
$ids['delta']['type'] = 'string';
|
||||
$ids['theme']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Book.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 book source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_book"
|
||||
* )
|
||||
*/
|
||||
class Book extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('book', 'b')->fields('b', array('nid', 'bid'));
|
||||
$query->join('menu_links', 'ml', 'b.mlid = ml.mlid');
|
||||
$ml_fields = array('mlid', 'plid', 'weight', 'has_children', 'depth');
|
||||
for ($i = 1; $i <= 9; $i++) {
|
||||
$field = "p$i";
|
||||
$ml_fields[] = $field;
|
||||
$query->orderBy($field);
|
||||
}
|
||||
$query->fields('ml', $ml_fields);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['mlid']['type'] = 'integer';
|
||||
$ids['mlid']['alias'] = 'ml';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'nid' => $this->t('Node ID'),
|
||||
'bid' => $this->t('Book ID'),
|
||||
'mlid' => $this->t('Menu link ID'),
|
||||
'plid' => $this->t('Parent link ID'),
|
||||
'weight' => $this->t('Weight'),
|
||||
'p1' => $this->t('The first mlid in the materialized path.'),
|
||||
'p2' => $this->t('The second mlid in the materialized path.'),
|
||||
'p3' => $this->t('The third mlid in the materialized path.'),
|
||||
'p4' => $this->t('The fourth mlid in the materialized path.'),
|
||||
'p5' => $this->t('The fifth mlid in the materialized path.'),
|
||||
'p6' => $this->t('The sixth mlid in the materialized path.'),
|
||||
'p7' => $this->t('The seventh mlid in the materialized path.'),
|
||||
'p8' => $this->t('The eight mlid in the materialized path.'),
|
||||
'p9' => $this->t('The nine mlid in the materialized path.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Box.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 block source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_box"
|
||||
* )
|
||||
*/
|
||||
class Box extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('boxes', 'b')
|
||||
->fields('b', array('bid', 'body', 'info', 'format'));
|
||||
$query->orderBy('bid');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'bid' => $this->t('The numeric identifier of the block/box'),
|
||||
'body' => $this->t('The block/box content'),
|
||||
'info' => $this->t('Admin title of the block/box.'),
|
||||
'format' => $this->t('Input format of the custom block/box content.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['bid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CckFieldRevision.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Drupal 6 cck field revision source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_cck_field_revision"
|
||||
* )
|
||||
*/
|
||||
class CckFieldRevision extends CckFieldValues {
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions_table.
|
||||
*/
|
||||
const JOIN = 'n.nid = nr.nid AND n.vid <> nr.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
// Use all the node fields plus the vid that identifies the version.
|
||||
return parent::fields() + array('vid' => t('The primary identifier for this version.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'nr';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,318 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CckFieldValues.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate_drupal\Plugin\CckFieldMigrateSourceInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Drupal 6 cck field source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_cck_field_values"
|
||||
* )
|
||||
*/
|
||||
class CckFieldValues extends DrupalSqlBase implements SourceEntityInterface, CckFieldMigrateSourceInterface {
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions table.
|
||||
*/
|
||||
const JOIN = 'n.vid = nr.vid';
|
||||
|
||||
/**
|
||||
* The source field information for complex node fields.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $sourceFieldInfo;
|
||||
|
||||
/**
|
||||
* Information on which tables exist.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $tables;
|
||||
|
||||
/**
|
||||
* TRUE when CCK is enabled and the schema is correct.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $cckSchemaCorrect;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Select node in its last revision.
|
||||
$query = $this->select('node_revisions', 'nr')
|
||||
->fields('n', array(
|
||||
'nid',
|
||||
'type',
|
||||
))
|
||||
->fields('nr', array(
|
||||
'vid',
|
||||
))
|
||||
->condition('type', $this->configuration['bundle']);
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$bundle = $row->getSourceProperty('type');
|
||||
// Pick up simple CCK fields.
|
||||
$cck_table = "content_type_$bundle";
|
||||
if ($this->tableExists($cck_table)) {
|
||||
$query = $this->select($cck_table, 'f')->condition('vid', $row->getSourceProperty('vid'));
|
||||
// The main column for the field should be rendered with the field name,
|
||||
// not the column name (e.g., field_foo rather than field_foo_value).
|
||||
$field_info = $this->getSourceFieldInfo($bundle);
|
||||
foreach ($field_info as $field_name => $info) {
|
||||
if (isset($info['columns']) && !$info['multiple'] && $info['db_storage']) {
|
||||
$i = 0;
|
||||
$data = FALSE;
|
||||
foreach ($info['columns'] as $display_name => $column_name) {
|
||||
if ($i++ == 0) {
|
||||
$query->addField('f', $column_name, $field_name);
|
||||
}
|
||||
else {
|
||||
// The database API won't allow colons in column aliases, so we
|
||||
// will accept the default alias, and fix up the field names later.
|
||||
// Remember how to translate the field names.
|
||||
if ($info['type'] == 'filefield' &&
|
||||
(strpos($display_name, ':list') || strpos($display_name, ':description'))) {
|
||||
if (!$data) {
|
||||
//$this->fileDataFields[] = $field_name . '_data';
|
||||
$query->addField('f', $field_name . '_data');
|
||||
$data = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$query->addField('f', $column_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The $query only contains single value CCK fields and so when the only
|
||||
// CCK field attached to a content type is a multi-valued CCK field then
|
||||
// this query would be invalid. Checking the count tells us if any single
|
||||
// fields have been added the query.
|
||||
if (count($query->getFields())) {
|
||||
if ($results = $query->execute()->fetchAssoc()) {
|
||||
$source = $row->getSource();
|
||||
// We diff the results with the source to find any field columns
|
||||
// in the content type's main table.
|
||||
$new_fields = array_diff_key($results, $source);
|
||||
foreach ($new_fields as $key => $value) {
|
||||
$row->setSourceProperty($key, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle fields that have their own table.
|
||||
foreach ($this->getSourceFieldInfo($bundle) as $field_name => $field_info) {
|
||||
if ($field_info['multiple'] || !$field_info['db_storage']) {
|
||||
// Select the data.
|
||||
$table = "content_$field_name";
|
||||
$field_query = $this
|
||||
->select($table, 't')
|
||||
->condition('vid', $row->getSourceProperty('vid'));
|
||||
if ($field_info['multiple']) {
|
||||
$field_query->addField('t', 'delta');
|
||||
}
|
||||
$data = FALSE;
|
||||
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||
// The database API won't allow colons in column aliases, so we
|
||||
// will accept the default alias, and fix up the field names later.
|
||||
// Remember how to translate the field names.
|
||||
if ($field_info['type'] == 'filefield' &&
|
||||
(strpos($display_name, ':list') || strpos($display_name, ':description'))) {
|
||||
if (!$data) {
|
||||
//$this->fileDataFields[] = $field_name . '_data';
|
||||
$field_query->addField('t', $field_name . '_data');
|
||||
$data = TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$field_query->addField('t', $column_name);
|
||||
}
|
||||
}
|
||||
|
||||
if ($field_info['multiple']) {
|
||||
foreach ($field_query->execute() as $field_row) {
|
||||
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||
list ( , $column) = explode(':', $display_name);
|
||||
$property_path = $field_name . Row::PROPERTY_SEPARATOR . $field_row['delta'] . Row::PROPERTY_SEPARATOR . $column;
|
||||
$row->setSourceProperty($property_path, $field_row[$column_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($field_row = $field_query->execute()->fetchAssoc()) {
|
||||
foreach ($field_info['columns'] as $display_name => $column_name) {
|
||||
$row->setSourceProperty(str_replace(':', Row::PROPERTY_SEPARATOR, $display_name), $field_row[$column_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the complex field info.
|
||||
*
|
||||
* @param string $bundle
|
||||
* The bundle for which fields we want.
|
||||
*
|
||||
* @return array
|
||||
* An array of field info keyed by field name.
|
||||
*/
|
||||
protected function getSourceFieldInfo($bundle) {
|
||||
if (!isset($this->sourceFieldInfo)) {
|
||||
$this->sourceFieldInfo = array();
|
||||
if ($this->tableExists('content_node_field_instance')) {
|
||||
// Get each field attached to this type.
|
||||
$query = $this->select('content_node_field_instance', 'i')
|
||||
->fields('i', array(
|
||||
'label',
|
||||
'widget_settings',
|
||||
'field_name',
|
||||
))
|
||||
->condition('type_name', $bundle);
|
||||
|
||||
$query->innerJoin('content_node_field', 'f', 'i.field_name = f.field_name');
|
||||
$query->fields('f', array(
|
||||
'field_name',
|
||||
'type',
|
||||
'db_columns',
|
||||
'global_settings',
|
||||
'multiple',
|
||||
'db_storage')
|
||||
);
|
||||
|
||||
$results = $query->execute();
|
||||
foreach ($results as $row) {
|
||||
$field_name = trim($row['field_name']);
|
||||
$db_columns = $db_columns = !empty($row['db_columns']) ? unserialize($row['db_columns']) : array();
|
||||
$columns = array();
|
||||
foreach ($db_columns as $column_name => $column_info) {
|
||||
// Special handling for the stuff packed into filefield's "data"
|
||||
if ($row['type'] == 'filefield' && $column_name == 'data') {
|
||||
$widget_settings = unserialize($row['widget_settings']);
|
||||
$global_settings = unserialize($row['global_settings']);
|
||||
|
||||
if (!empty($widget_settings['custom_alt'])) {
|
||||
$columns[$field_name . ':alt'] = $field_name . '_alt';
|
||||
}
|
||||
if (!empty($widget_settings['custom_title'])) {
|
||||
$columns[$field_name . ':title'] = $field_name . '_title';
|
||||
}
|
||||
if (!empty($global_settings['description_field'])) {
|
||||
$columns[$field_name . ':description'] = $field_name . '_description';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$display_name = $field_name . ':' . $column_name;
|
||||
$column_name = $field_name . '_' . $column_name;
|
||||
$columns[$display_name] = $column_name;
|
||||
}
|
||||
}
|
||||
$this->sourceFieldInfo[$field_name] = array(
|
||||
'label' => $row['label'],
|
||||
'type' => $row['type'],
|
||||
'columns' => $columns,
|
||||
'multiple' => $row['multiple'],
|
||||
'db_storage' => $row['db_storage'],
|
||||
'bundle' => $bundle,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->sourceFieldInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
);
|
||||
foreach ($this->getSourceFieldInfo($this->configuration['bundle']) as $field_name => $field_data) {
|
||||
$fields[$field_name] = $field_data['label'];
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fieldData() {
|
||||
$field_info = $this->getSourceFieldInfo($this->configuration['bundle']);
|
||||
$field_info['nid'] = ['type' => 'number'];
|
||||
$field_info['type'] = ['type' => 'varchar'];
|
||||
return $field_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['nid']['alias'] = 'n';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'node';
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether a specific CCK table exists.
|
||||
*/
|
||||
protected function tableExists($table) {
|
||||
if (!isset($this->tables[$table])) {
|
||||
$this->tables[$table] = $this->cckSchemaCorrect() && $this->getDatabase()->schema()->tableExists($table);
|
||||
}
|
||||
return $this->tables[$table];
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether CCK is enabled and is using the right schema.
|
||||
*/
|
||||
protected function cckSchemaCorrect() {
|
||||
if (!isset($this->cckSchemaCorrect)) {
|
||||
$this->cckSchemaCorrect = $this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001;
|
||||
}
|
||||
return $this->cckSchemaCorrect;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Comment.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 comment source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_comment",
|
||||
* source_provider = "comment"
|
||||
* )
|
||||
*/
|
||||
class Comment extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('comments', 'c')
|
||||
->fields('c', array('cid', 'pid', 'nid', 'uid', 'subject',
|
||||
'comment', 'hostname', 'timestamp', 'status', 'thread', 'name',
|
||||
'mail', 'homepage', 'format'));
|
||||
$query->innerJoin('node', 'n', 'c.nid = n.nid');
|
||||
$query->fields('n', array('type'));
|
||||
$query->orderBy('c.timestamp');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
if ($this->variableGet('comment_subject_field_' . $row->getSourceProperty('type'), 1)) {
|
||||
// Comment subject visible.
|
||||
$row->setSourceProperty('field_name', 'comment');
|
||||
$row->setSourceProperty('comment_type', 'comment');
|
||||
}
|
||||
else {
|
||||
$row->setSourceProperty('field_name', 'comment_no_subject');
|
||||
$row->setSourceProperty('comment_type', 'comment_no_subject');
|
||||
}
|
||||
// In D6, status=0 means published, while in D8 means the opposite.
|
||||
// See https://www.drupal.org/node/237636.
|
||||
$row->setSourceProperty('status', !$row->getSourceProperty('status'));
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'cid' => $this->t('Comment ID.'),
|
||||
'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'),
|
||||
'nid' => $this->t('The {node}.nid to which this comment is a reply.'),
|
||||
'uid' => $this->t('The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.'),
|
||||
'subject' => $this->t('The comment title.'),
|
||||
'comment' => $this->t('The comment body.'),
|
||||
'hostname' => $this->t("The author's host name."),
|
||||
'timestamp' => $this->t('The time that the comment was created, or last edited by its author, as a Unix timestamp.'),
|
||||
'status' => $this->t('The published status of a comment. (0 = Published, 1 = Not Published)'),
|
||||
'format' => $this->t('The {filter_formats}.format of the comment body.'),
|
||||
'thread' => $this->t("The vancode representation of the comment's place in a thread."),
|
||||
'name' => $this->t("The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form."),
|
||||
'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
|
||||
'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."),
|
||||
'type' => $this->t("The {node}.type to which this comment is a reply."),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['cid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CommentVariable.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "d6_comment_variable"
|
||||
* )
|
||||
*/
|
||||
class CommentVariable extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
return new \ArrayIterator($this->getCommentVariables());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->getCommentVariables());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the values of the comment variables grouped by node type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCommentVariables() {
|
||||
$comment_prefixes = array_keys($this->commentPrefixes());
|
||||
$variables = array();
|
||||
$node_types = $this->getDatabase()->query('SELECT type FROM {node_type}')->fetchCol();
|
||||
foreach ($node_types as $node_type) {
|
||||
foreach ($comment_prefixes as $prefix) {
|
||||
$variables[] = $prefix . '_' . $node_type;
|
||||
}
|
||||
}
|
||||
$return = array();
|
||||
$values = $this->getDatabase()->query('SELECT name, value FROM {variable} WHERE name IN ( :name[] )', array(':name[]' => $variables))->fetchAllKeyed();
|
||||
foreach ($node_types as $node_type) {
|
||||
foreach ($comment_prefixes as $prefix) {
|
||||
$name = $prefix . '_' . $node_type;
|
||||
if (isset($values[$name])) {
|
||||
$return[$node_type][$prefix] = unserialize($values[$name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// The return key will not be used so move it inside the row. This could
|
||||
// not be done sooner because otherwise empty rows would be created with
|
||||
// just the node type in it.
|
||||
foreach ($return as $node_type => $data) {
|
||||
$return[$node_type]['node_type'] = $node_type;
|
||||
$return[$node_type]['comment_type'] = empty($data['comment_subject_field']) ?
|
||||
'comment_no_subject' : 'comment';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return $this->commentPrefixes() + array(
|
||||
'node_type' => $this->t('The node type'),
|
||||
'comment_type' => $this->t('The comment type'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Comment related data for fields.
|
||||
*/
|
||||
protected function commentPrefixes() {
|
||||
return array(
|
||||
'comment' => $this->t('Default comment setting'),
|
||||
'comment_default_mode' => $this->t('Default display mode'),
|
||||
'comment_default_order' => $this->t('Default display order'),
|
||||
'comment_default_per_page' => $this->t('Default comments per page'),
|
||||
'comment_controls' => $this->t('Comment controls'),
|
||||
'comment_anonymous' => $this->t('Anonymous commenting'),
|
||||
'comment_subject_field' => $this->t('Comment subject field'),
|
||||
'comment_preview' => $this->t('Preview comment'),
|
||||
'comment_form_location' => $this->t('Location of comment submission form'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['node_type']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\CommentVariablePerCommentType.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "d6_comment_variable_per_comment_type"
|
||||
* )
|
||||
*/
|
||||
class CommentVariablePerCommentType extends CommentVariable {
|
||||
|
||||
/**
|
||||
* Retrieves the values of the comment variables grouped by comment type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getCommentVariables() {
|
||||
$node_types = parent::getCommentVariables();
|
||||
// The return key used to separate comment types with hidden subject field.
|
||||
$return = array();
|
||||
foreach ($node_types as $node_type => $data) {
|
||||
// Only 2 comment types depending on subject field visibility.
|
||||
if (empty($data['comment_subject_field'])) {
|
||||
// Default label and description should be set in migration.
|
||||
$return['comment'] = array(
|
||||
'comment_type' => 'comment',
|
||||
'label' => $this->t('Default comments'),
|
||||
'description' => $this->t('Allows commenting on content')
|
||||
);
|
||||
}
|
||||
else {
|
||||
// Provide a special comment type with hidden subject field.
|
||||
$return['comment_no_subject'] = array(
|
||||
'comment_type' => 'comment_no_subject',
|
||||
'label' => $this->t('Comments without subject field'),
|
||||
'description' => $this->t('Allows commenting on content, comments without subject field')
|
||||
);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'comment_type' => $this->t('The comment type'),
|
||||
'label' => $this->t('The comment type label'),
|
||||
'description' => $this->t('The comment type description'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['comment_type']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ContactCategory.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 contact category source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_contact_category",
|
||||
* source_provider = "contact"
|
||||
* )
|
||||
*/
|
||||
class ContactCategory extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('contact', 'c')
|
||||
->fields('c', array(
|
||||
'cid',
|
||||
'category',
|
||||
'recipients',
|
||||
'reply',
|
||||
'weight',
|
||||
'selected',
|
||||
)
|
||||
);
|
||||
$query->orderBy('cid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('recipients', explode(',', $row->getSourceProperty('recipients')));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'cid' => $this->t('Primary Key: Unique category ID.'),
|
||||
'category' => $this->t('Category name.'),
|
||||
'recipients' => $this->t('Comma-separated list of recipient email addresses.'),
|
||||
'reply' => $this->t('Text of the auto-reply message.'),
|
||||
'weight' => $this->t("The category's weight."),
|
||||
'selected' => $this->t('Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['cid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ContactSettings.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\Variable;
|
||||
|
||||
/**
|
||||
* @MigrateSource(
|
||||
* id = "d6_contact_settings",
|
||||
* source_provider = "contact"
|
||||
* )
|
||||
*/
|
||||
class ContactSettings extends Variable {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function initializeIterator() {
|
||||
$default_category = $this->select('contact', 'c')
|
||||
->fields('c', array('cid'))
|
||||
->condition('selected', 1)
|
||||
->execute()
|
||||
->fetchField();
|
||||
return new \ArrayIterator(array($this->values() + array('default_category' => $default_category)));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Field.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 field source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class Field extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field', 'cnf')
|
||||
->fields('cnf', array(
|
||||
'field_name',
|
||||
'type',
|
||||
'global_settings',
|
||||
'required',
|
||||
'multiple',
|
||||
'db_storage',
|
||||
'module',
|
||||
'db_columns',
|
||||
'active',
|
||||
'locked',
|
||||
))
|
||||
->fields('cnfi', array(
|
||||
'widget_type',
|
||||
'widget_settings',
|
||||
));
|
||||
$query->join('content_node_field_instance', 'cnfi', 'cnfi.field_name = cnf.field_name');
|
||||
$query->orderBy('field_name');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('Field name'),
|
||||
'type' => $this->t('Type (text, integer, ....)'),
|
||||
'global_settings' => $this->t('Global settings. Shared with every field instance.'),
|
||||
'required' => $this->t('Required'),
|
||||
'multiple' => $this->t('Multiple'),
|
||||
'db_storage' => $this->t('DB storage'),
|
||||
'module' => $this->t('Module'),
|
||||
'db_columns' => $this->t('DB Columns'),
|
||||
'active' => $this->t('Active'),
|
||||
'locked' => $this->t('Locked'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Unserialize data.
|
||||
$global_settings = unserialize($row->getSourceProperty('global_settings'));
|
||||
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
|
||||
$db_columns = unserialize($row->getSourceProperty('db_columns'));
|
||||
$row->setSourceProperty('global_settings', $global_settings);
|
||||
$row->setSourceProperty('widget_settings', $widget_settings);
|
||||
$row->setSourceProperty('db_columns', $db_columns);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['field_name'] = array(
|
||||
'type' => 'string',
|
||||
'alias' => 'cnf',
|
||||
);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 field instances source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field_instance",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class FieldInstance extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'field_name',
|
||||
'type_name',
|
||||
'weight',
|
||||
'label',
|
||||
'widget_type',
|
||||
'widget_settings',
|
||||
'display_settings',
|
||||
'description',
|
||||
'widget_module',
|
||||
'widget_active',
|
||||
'description',
|
||||
))
|
||||
->fields('cnf', array(
|
||||
'required',
|
||||
'active',
|
||||
'global_settings',
|
||||
));
|
||||
|
||||
$query->join('content_node_field', 'cnf', 'cnf.field_name = cnfi.field_name');
|
||||
$query->orderBy('weight');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('The machine name of field.'),
|
||||
'type_name' => $this->t('Content type where is used this field.'),
|
||||
'weight' => $this->t('Weight.'),
|
||||
'label' => $this->t('A name to show.'),
|
||||
'widget_type' => $this->t('Widget type.'),
|
||||
'widget_settings' => $this->t('Serialize data with widget settings.'),
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
'description' => $this->t('A description of field.'),
|
||||
'widget_module' => $this->t('Module that implements widget.'),
|
||||
'widget_active' => $this->t('Status of widget'),
|
||||
'module' => $this->t('The module that provides the field.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Unserialize data.
|
||||
$widget_settings = unserialize($row->getSourceProperty('widget_settings'));
|
||||
$display_settings = unserialize($row->getSourceProperty('display_settings'));
|
||||
$global_settings = unserialize($row->getSourceProperty('global_settings'));
|
||||
$row->setSourceProperty('widget_settings', $widget_settings);
|
||||
$row->setSourceProperty('display_settings', $display_settings);
|
||||
$row->setSourceProperty('global_settings', $global_settings);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids = array(
|
||||
'field_name' => array(
|
||||
'type' => 'string',
|
||||
'alias' => 'cnfi',
|
||||
),
|
||||
'type_name' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
);
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstancePerFormDisplay.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* The field instance per form display source class.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field_instance_per_form_display"
|
||||
* )
|
||||
*/
|
||||
class FieldInstancePerFormDisplay extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$rows = array();
|
||||
$result = $this->prepareQuery()->execute();
|
||||
while ($field_row = $result->fetchAssoc()) {
|
||||
$field_row['display_settings'] = unserialize($field_row['display_settings']);
|
||||
$field_row['widget_settings'] = unserialize($field_row['widget_settings']);
|
||||
$bundle = $field_row['type_name'];
|
||||
$field_name = $field_row['field_name'];
|
||||
|
||||
$index = "$bundle.$field_name";
|
||||
$rows[$index]['type_name'] = $bundle;
|
||||
$rows[$index]['widget_active'] = (bool) $field_row['widget_active'];
|
||||
$rows[$index]['field_name'] = $field_name;
|
||||
$rows[$index]['type'] = $field_row['type'];
|
||||
$rows[$index]['module'] = $field_row['module'];
|
||||
$rows[$index]['weight'] = $field_row['weight'];
|
||||
$rows[$index]['widget_type'] = $field_row['widget_type'];
|
||||
$rows[$index]['widget_settings'] = $field_row['widget_settings'];
|
||||
}
|
||||
|
||||
return new \ArrayIterator($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'field_name',
|
||||
'type_name',
|
||||
'weight',
|
||||
'label',
|
||||
'widget_type',
|
||||
'widget_settings',
|
||||
'display_settings',
|
||||
'description',
|
||||
'widget_module',
|
||||
'widget_active',
|
||||
))
|
||||
->fields('cnf', array(
|
||||
'type',
|
||||
'module',
|
||||
));
|
||||
$query->join('content_node_field', 'cnf', 'cnfi.field_name = cnf.field_name');
|
||||
$query->orderBy('weight');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('The machine name of field.'),
|
||||
'type_name' => $this->t('Content type where this field is used.'),
|
||||
'weight' => $this->t('Weight.'),
|
||||
'label' => $this->t('A name to show.'),
|
||||
'widget_type' => $this->t('Widget type.'),
|
||||
'widget_settings' => $this->t('Serialize data with widget settings.'),
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
'description' => $this->t('A description of field.'),
|
||||
'widget_module' => $this->t('Module that implements widget.'),
|
||||
'widget_active' => $this->t('Status of widget'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['type_name']['type'] = 'string';
|
||||
$ids['field_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FieldInstancePerViewMode.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* The field instance per view mode source class.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_field_instance_per_view_mode",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class FieldInstancePerViewMode extends ViewModeBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$rows = array();
|
||||
$result = $this->prepareQuery()->execute();
|
||||
while ($field_row = $result->fetchAssoc()) {
|
||||
// These are added to every view mode row.
|
||||
$field_row['display_settings'] = unserialize($field_row['display_settings']);
|
||||
$field_row['widget_settings'] = unserialize($field_row['widget_settings']);
|
||||
$bundle = $field_row['type_name'];
|
||||
$field_name = $field_row['field_name'];
|
||||
|
||||
foreach ($this->getViewModes() as $view_mode) {
|
||||
if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
|
||||
$index = $view_mode . "." . $bundle . "." . $field_name;
|
||||
$rows[$index]['entity_type'] = 'node';
|
||||
$rows[$index]['view_mode'] = $view_mode;
|
||||
$rows[$index]['type_name'] = $bundle;
|
||||
$rows[$index]['field_name'] = $field_name;
|
||||
$rows[$index]['type'] = $field_row['type'];
|
||||
$rows[$index]['module'] = $field_row['module'];
|
||||
$rows[$index]['weight'] = $field_row['weight'];
|
||||
$rows[$index]['label'] = $field_row['display_settings']['label']['format'];
|
||||
$rows[$index]['display_settings'] = $field_row['display_settings'][$view_mode];
|
||||
$rows[$index]['widget_settings'] = $field_row['widget_settings'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new \ArrayIterator($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'field_name',
|
||||
'type_name',
|
||||
'weight',
|
||||
'label',
|
||||
'display_settings',
|
||||
'widget_settings',
|
||||
))
|
||||
->fields('cnf', array(
|
||||
'type',
|
||||
'module',
|
||||
));
|
||||
$query->join('content_node_field', 'cnf', 'cnfi.field_name = cnf.field_name');
|
||||
$query->orderBy('weight');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'field_name' => $this->t('The machine name of field.'),
|
||||
'type_name' => $this->t('Content type where this field is used.'),
|
||||
'weight' => $this->t('Weight.'),
|
||||
'label' => $this->t('A name to show.'),
|
||||
'widget_type' => $this->t('Widget type.'),
|
||||
'widget_settings' => $this->t('Serialize data with widget settings.'),
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
'description' => $this->t('A description of field.'),
|
||||
'widget_module' => $this->t('Module that implements widget.'),
|
||||
'widget_active' => $this->t('Status of widget'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['type_name']['type'] = 'string';
|
||||
$ids['view_mode']['type'] = 'string';
|
||||
$ids['entity_type']['type'] = 'string';
|
||||
$ids['field_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\File.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 file source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_file"
|
||||
* )
|
||||
*/
|
||||
class File extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The file directory path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filePath;
|
||||
|
||||
/**
|
||||
* The temporary file path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFilePath;
|
||||
|
||||
/**
|
||||
* Flag for private or public file storage.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isPublic;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('files', 'f')->fields('f', array(
|
||||
'fid',
|
||||
'uid',
|
||||
'filename',
|
||||
'filepath',
|
||||
'filemime',
|
||||
'filesize',
|
||||
'status',
|
||||
'timestamp',
|
||||
));
|
||||
$query->orderBy('timestamp');
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
|
||||
$this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
|
||||
$this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
|
||||
|
||||
// FILE_DOWNLOADS_PUBLIC == 1 and FILE_DOWNLOADS_PRIVATE == 2.
|
||||
$this->isPublic = $this->variableGet('file_downloads', 1) == 1;
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('file_directory_path', $this->filePath);
|
||||
$row->setSourceProperty('temp_directory_path', $this->tempFilePath);
|
||||
$row->setSourceProperty('is_public', $this->isPublic);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('File ID'),
|
||||
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
|
||||
'filename' => $this->t('File name'),
|
||||
'filepath' => $this->t('File path'),
|
||||
'filemime' => $this->t('File Mime Type'),
|
||||
'status' => $this->t('The published status of a file.'),
|
||||
'timestamp' => $this->t('The time that the file was added.'),
|
||||
'file_directory_path' => $this->t('The Drupal files path.'),
|
||||
'is_public' => $this->t('TRUE if the files directory is public otherwise FALSE.'),
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\FilterFormat.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 role source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_filter_format"
|
||||
* )
|
||||
*/
|
||||
class FilterFormat extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('filter_formats', 'f')
|
||||
->fields('f', array('format', 'name', 'roles', 'cache'))
|
||||
->orderBy('format');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'format' => $this->t('Format ID.'),
|
||||
'name' => $this->t('The name of the filter format.'),
|
||||
'roles' => $this->t('The user roles that can use the format.'),
|
||||
'cache' => $this->t('Flag to indicate whether format is cacheable. (1 = cacheable, 0 = not cacheable).'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$filters = array();
|
||||
$roles = $row->getSourceProperty('roles');
|
||||
$row->setSourceProperty('roles', array_values(array_filter(explode(',', $roles))));
|
||||
$format = $row->getSourceProperty('format');
|
||||
// Find filters for this row.
|
||||
$results = $this->database
|
||||
->select('filters', 'f', array('fetch' => \PDO::FETCH_ASSOC))
|
||||
->fields('f', array('module', 'delta', 'weight'))
|
||||
->condition('format', $format)
|
||||
->execute();
|
||||
foreach ($results as $raw_filter) {
|
||||
$module = $raw_filter['module'];
|
||||
$delta = $raw_filter['delta'];
|
||||
$filter = array(
|
||||
'module' => $module,
|
||||
'delta' => $delta,
|
||||
'weight' => $raw_filter['weight'],
|
||||
'settings' => array(),
|
||||
);
|
||||
// Load the filter settings for the filter module, modules can use
|
||||
// hook_migration_d6_filter_formats_prepare_row() to add theirs.
|
||||
if ($raw_filter['module'] == 'filter') {
|
||||
if (!$delta) {
|
||||
if ($setting = $this->variableGet("allowed_html_$format", NULL)) {
|
||||
$filter['settings']['allowed_html'] = $setting;
|
||||
}
|
||||
if ($setting = $this->variableGet("filter_html_help_$format", NULL)) {
|
||||
$filter['settings']['filter_html_help'] = $setting;
|
||||
}
|
||||
if ($setting = $this->variableGet("filter_html_nofollow_$format", NULL)) {
|
||||
$filter['settings']['filter_html_nofollow'] = $setting;
|
||||
}
|
||||
}
|
||||
elseif ($delta == 2 && ($setting = $this->variableGet("filter_url_length_$format", NULL))) {
|
||||
$filter['settings']['filter_url_length'] = $setting;
|
||||
}
|
||||
}
|
||||
$filters[] = $filter;
|
||||
}
|
||||
|
||||
$row->setSourceProperty('filters', $filters);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['format']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Menu.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 menu source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_menu",
|
||||
* source_provider = "menu"
|
||||
* )
|
||||
*/
|
||||
class Menu extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('menu_custom', 'm')
|
||||
->fields('m', array('menu_name', 'title', 'description'));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'menu_name' => $this->t('The menu name. Primary key.'),
|
||||
'title' => $this->t('The human-readable name of the menu.'),
|
||||
'description' => $this->t('A description of the menu'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['menu_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\MenuLink.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 menu link source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_menu_link",
|
||||
* )
|
||||
*/
|
||||
class MenuLink extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('menu_links', 'ml')
|
||||
->fields('ml', array(
|
||||
'menu_name',
|
||||
'mlid',
|
||||
'plid',
|
||||
'link_path',
|
||||
'router_path',
|
||||
'link_title',
|
||||
'options',
|
||||
'module',
|
||||
'hidden',
|
||||
'external',
|
||||
'has_children',
|
||||
'expanded',
|
||||
'weight',
|
||||
'depth',
|
||||
'customized',
|
||||
'p1',
|
||||
'p2',
|
||||
'p3',
|
||||
'p4',
|
||||
'p5',
|
||||
'p6',
|
||||
'p7',
|
||||
'p8',
|
||||
'p9',
|
||||
'updated'
|
||||
))
|
||||
->condition('module', 'menu')
|
||||
->condition('customized', 1);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'menu_name' => t("The menu name. All links with the same menu name (such as 'navigation') are part of the same menu."),
|
||||
'mlid' => t('The menu link ID (mlid) is the integer primary key.'),
|
||||
'plid' => t('The parent link ID (plid) is the mlid of the link above in the hierarchy, or zero if the link is at the top level in its menu.'),
|
||||
'link_path' => t('The Drupal path or external path this link points to.'),
|
||||
'router_path' => t('For links corresponding to a Drupal path (external = 0), this connects the link to a {menu_router}.path for joins.'),
|
||||
'link_title' => t('The text displayed for the link, which may be modified by a title callback stored in {menu_router}.'),
|
||||
'options' => t('A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.'),
|
||||
'module' => t('The name of the module that generated this link.'),
|
||||
'hidden' => t('A flag for whether the link should be rendered in menus. (1 = a disabled menu item that may be shown on admin screens, -1 = a menu callback, 0 = a normal, visible link)'),
|
||||
'external' => t('A flag to indicate if the link points to a full URL starting with a protocol, like http:// (1 = external, 0 = internal).'),
|
||||
'has_children' => t('Flag indicating whether any links have this link as a parent (1 = children exist, 0 = no children).'),
|
||||
'expanded' => t('Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)'),
|
||||
'weight' => t('Link weight among links in the same menu at the same depth.'),
|
||||
'depth' => t('The depth relative to the top level. A link with plid == 0 will have depth == 1.'),
|
||||
'customized' => t('A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized).'),
|
||||
'p1' => t('The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the plid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.'),
|
||||
'p2' => t('The second mlid in the materialized path. See p1.'),
|
||||
'p3' => t('The third mlid in the materialized path. See p1.'),
|
||||
'p4' => t('The fourth mlid in the materialized path. See p1.'),
|
||||
'p5' => t('The fifth mlid in the materialized path. See p1.'),
|
||||
'p6' => t('The sixth mlid in the materialized path. See p1.'),
|
||||
'p7' => t('The seventh mlid in the materialized path. See p1.'),
|
||||
'p8' => t('The eighth mlid in the materialized path. See p1.'),
|
||||
'p9' => t('The ninth mlid in the materialized path. See p1.'),
|
||||
'updated' => t('Flag that indicates that this link was generated during the update from Drupal 5.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
|
||||
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['mlid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Node.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 node source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_node"
|
||||
* )
|
||||
*/
|
||||
class Node extends DrupalSqlBase implements SourceEntityInterface {
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions table.
|
||||
*/
|
||||
const JOIN = 'n.vid = nr.vid';
|
||||
|
||||
/**
|
||||
* The default filter format.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filterDefaultFormat;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Select node in its last revision.
|
||||
$query = $this->select('node_revisions', 'nr')
|
||||
->fields('n', array(
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'moderate',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
))
|
||||
->fields('nr', array(
|
||||
'vid',
|
||||
'title',
|
||||
'body',
|
||||
'teaser',
|
||||
'log',
|
||||
'timestamp',
|
||||
'format',
|
||||
));
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$this->filterDefaultFormat = $this->variableGet('filter_default_format', '1');
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'body' => $this->t('Body'),
|
||||
'format' => $this->t('Format'),
|
||||
'teaser' => $this->t('Teaser'),
|
||||
'node_uid' => $this->t('Node authored by (uid)'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'status' => $this->t('Published'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'revision' => $this->t('Create new revision'),
|
||||
'language' => $this->t('Language (fr, en, ...)'),
|
||||
'tnid' => $this->t('The translation set id for this node'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// format = 0 can happen when the body field is hidden. Set the format to 1
|
||||
// to avoid migration map issues (since the body field isn't used anyway).
|
||||
if ($row->getSourceProperty('format') === '0') {
|
||||
$row->setSourceProperty('format', $this->filterDefaultFormat);
|
||||
}
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['nid']['type'] = 'integer';
|
||||
$ids['nid']['alias'] = 'n';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'node';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeRevision.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Drupal 6 node revision source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_node_revision"
|
||||
* )
|
||||
*/
|
||||
class NodeRevision extends Node {
|
||||
|
||||
/**
|
||||
* The join options between the node and the node_revisions_table.
|
||||
*/
|
||||
const JOIN = 'n.nid = nr.nid AND n.vid <> nr.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
// Use all the node fields plus the vid that identifies the version.
|
||||
return parent::fields() + array(
|
||||
'vid' => t('The primary identifier for this version.'),
|
||||
'log' => $this->t('Revision Log message'),
|
||||
'timestamp' => $this->t('Revision timestamp'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'nr';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\NodeType.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 Node types source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_node_type"
|
||||
* )
|
||||
*/
|
||||
class NodeType extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The teaser length
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $teaserLength;
|
||||
|
||||
/**
|
||||
* Node preview optional / required.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $nodePreview;
|
||||
|
||||
/**
|
||||
* An array of theme settings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $themeSettings;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('node_type', 't')
|
||||
->fields('t', array(
|
||||
'type',
|
||||
'name',
|
||||
'module',
|
||||
'description',
|
||||
'help',
|
||||
'title_label',
|
||||
'has_body',
|
||||
'body_label',
|
||||
'min_word_count',
|
||||
'custom',
|
||||
'modified',
|
||||
'locked',
|
||||
'orig_type',
|
||||
))
|
||||
->orderBy('t.type');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'type' => $this->t('Machine name of the node type.'),
|
||||
'name' => $this->t('Human name of the node type.'),
|
||||
'module' => $this->t('The module providing the node type.'),
|
||||
'description' => $this->t('Description of the node type.'),
|
||||
'help' => $this->t('Help text for the node type.'),
|
||||
'title_label' => $this->t('Title label.'),
|
||||
'has_body' => $this->t('Flag indicating the node type has a body field.'),
|
||||
'body_label' => $this->t('Body label.'),
|
||||
'min_word_count' => $this->t('Minimum word count for the body field.'),
|
||||
'custom' => $this->t('Flag.'),
|
||||
'modified' => $this->t('Flag.'),
|
||||
'locked' => $this->t('Flag.'),
|
||||
'orig_type' => $this->t('The original type.'),
|
||||
'teaser_length' => $this->t('Teaser length'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$this->teaserLength = $this->variableGet('teaser_length', 600);
|
||||
$this->nodePreview = $this->variableGet('node_preview', 0);
|
||||
$this->themeSettings = $this->variableGet('theme_settings', array());
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('teaser_length', $this->teaserLength);
|
||||
$row->setSourceProperty('node_preview', $this->nodePreview);
|
||||
|
||||
$type = $row->getSourceProperty('type');
|
||||
$source_options = $this->variableGet('node_options_' . $type, array('promote', 'sticky'));
|
||||
$options = array();
|
||||
foreach (array('promote', 'sticky', 'status', 'revision') as $item) {
|
||||
$options[$item] = in_array($item, $source_options);
|
||||
}
|
||||
$row->setSourceProperty('options', $options);
|
||||
$submitted = isset($this->themeSettings['toggle_node_info_' . $type]) ? $this->themeSettings['toggle_node_info_' . $type] : FALSE;
|
||||
$row->setSourceProperty('display_submitted', $submitted);
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['type']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ProfileField.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 profile fields source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_profile_field",
|
||||
* source_provider = "profile"
|
||||
* )
|
||||
*/
|
||||
class ProfileField extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_fields', 'pf')
|
||||
->fields('pf', array(
|
||||
'fid',
|
||||
'title',
|
||||
'name',
|
||||
'explanation',
|
||||
'category',
|
||||
'page',
|
||||
'type',
|
||||
'weight',
|
||||
'required',
|
||||
'register',
|
||||
'visibility',
|
||||
'autocomplete',
|
||||
'options',
|
||||
));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
if ($row->getSourceProperty('type') == 'selection') {
|
||||
// Get the current options.
|
||||
$current_options = preg_split("/[\r\n]+/", $row->getSourceProperty('options'));
|
||||
// Select the list values from the profile_values table to ensure we get
|
||||
// them all since they can get out of sync with profile_fields.
|
||||
$options = $this->getDatabase()->query('SELECT DISTINCT value FROM {profile_values} WHERE fid = :fid', array(':fid' => $row->getSourceProperty('fid')))->fetchCol();
|
||||
$options = array_merge($current_options, $options);
|
||||
// array_combine() takes care of any duplicates options.
|
||||
$row->setSourceProperty('options', array_combine($options, $options));
|
||||
}
|
||||
|
||||
if ($row->getSourceProperty('type') == 'checkbox') {
|
||||
// D6 profile checkboxes values are always 0 or 1 (with no labels), so we
|
||||
// need to create two label-less options that will get 0 and 1 for their
|
||||
// keys.
|
||||
$row->setSourceProperty('options', array(NULL, NULL));
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('Primary Key: Unique profile field ID.'),
|
||||
'title' => $this->t('Title of the field shown to the end user.'),
|
||||
'name' => $this->t('Internal name of the field used in the form HTML and URLs.'),
|
||||
'explanation' => $this->t('Explanation of the field to end users.'),
|
||||
'category' => $this->t('Profile category that the field will be grouped under.'),
|
||||
'page' => $this->t("Title of page used for browsing by the field's value"),
|
||||
'type' => $this->t('Type of form field.'),
|
||||
'weight' => $this->t('Weight of field in relation to other profile fields.'),
|
||||
'required' => $this->t('Whether the user is required to enter a value. (0 = no, 1 = yes)'),
|
||||
'register' => $this->t('Whether the field is visible in the user registration form. (1 = yes, 0 = no)'),
|
||||
'visibility' => $this->t('The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)'),
|
||||
'autocomplete' => $this->t('Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)'),
|
||||
'options' => $this->t('List of options to be used in a list selection field.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ProfileFieldValues.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
|
||||
/**
|
||||
* Drupal 6 profile fields values source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_profile_field_values",
|
||||
* source_provider = "profile"
|
||||
* )
|
||||
*/
|
||||
class ProfileFieldValues extends DrupalSqlBase implements SourceEntityInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('profile_values', 'pv')
|
||||
->distinct()
|
||||
->fields('pv', array('fid', 'uid'));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Find profile values for this row.
|
||||
$query = $this->select('profile_values', 'pv')
|
||||
->fields('pv', array('fid', 'value'));
|
||||
$query->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
|
||||
$query->fields('pf', array('name', 'type'));
|
||||
$query->condition('uid', $row->getSourceProperty('uid'));
|
||||
$results = $query->execute();
|
||||
|
||||
foreach ($results as $profile_value) {
|
||||
// Check special case for date. We need to unserialize.
|
||||
if ($profile_value['type'] == 'date') {
|
||||
$date = unserialize($profile_value['value']);
|
||||
$date = date('Y-m-d', mktime(0, 0, 0, $date['month'], $date['day'], $date['year']));
|
||||
$row->setSourceProperty($profile_value['name'], array('value' => $date));
|
||||
}
|
||||
elseif ($profile_value['type'] == 'list') {
|
||||
// Explode by newline and comma.
|
||||
$row->setSourceProperty($profile_value['name'], preg_split("/[\r\n,]+/", $profile_value['value']));
|
||||
}
|
||||
else {
|
||||
$row->setSourceProperty($profile_value['name'], array($profile_value['value']));
|
||||
}
|
||||
}
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = array(
|
||||
'fid' => $this->t('Unique profile field ID.'),
|
||||
'uid' => $this->t('The user Id.'),
|
||||
'value' => $this->t('The value for this field.'),
|
||||
);
|
||||
|
||||
$query = $this->select('profile_values', 'pv')
|
||||
->fields('pv', array('fid', 'value'));
|
||||
$query->leftJoin('profile_fields', 'pf', 'pf.fid=pv.fid');
|
||||
$query->fields('pf', array('name', 'title'));
|
||||
$results = $query->execute();
|
||||
foreach ($results as $profile) {
|
||||
$fields[$profile['name']] = $this->t($profile['title']);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'uid' => array(
|
||||
'type' => 'integer',
|
||||
'alias' => 'pv',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Role.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 role source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_role"
|
||||
* )
|
||||
*/
|
||||
class Role extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* List of filter IDs per role IDs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $filterPermissions = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('role', 'r')
|
||||
->fields('r', array('rid', 'name'))
|
||||
->orderBy('rid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'rid' => $this->t('Role ID.'),
|
||||
'name' => $this->t('The name of the user role.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$filter_roles = $this->select('filter_formats', 'f')
|
||||
->fields('f', array('format', 'roles'))
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
foreach ($filter_roles as $format => $roles) {
|
||||
// Drupal 6 code: $roles = ','. implode(',', $roles) .',';
|
||||
// Remove the beginning and ending comma.
|
||||
foreach (explode(',', trim($roles, ',')) as $rid) {
|
||||
$this->filterPermissions[$rid][] = $format;
|
||||
}
|
||||
}
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$rid = $row->getSourceProperty('rid');
|
||||
$permissions = $this->select('permission', 'p')
|
||||
->fields('p', array('perm'))
|
||||
->condition('rid', $rid)
|
||||
->execute()
|
||||
->fetchField();
|
||||
$row->setSourceProperty('permissions', explode(', ', $permissions));
|
||||
if (isset($this->filterPermissions[$rid])) {
|
||||
$row->setSourceProperty("filter_permissions:$rid", $this->filterPermissions[$rid]);
|
||||
}
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['rid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Term.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 taxonomy terms source from database.
|
||||
*
|
||||
* @todo Support term_relation, term_synonym table if possible.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_taxonomy_term",
|
||||
* source_provider = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class Term extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Note the explode - this supports the (admittedly unusual) case of
|
||||
// consolidating multiple vocabularies into one.
|
||||
$query = $this->select('term_data', 'td')
|
||||
->fields('td', array('tid', 'vid', 'name', 'description', 'weight'))
|
||||
// This works, but we cannot test that, because there is no support for
|
||||
// distinct() in FakeSelect, yet.
|
||||
->distinct()
|
||||
->orderBy('tid');
|
||||
if (isset($this->configuration['vocabulary'])) {
|
||||
$query->condition('vid', $this->configuration['vocabulary'], 'IN');
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'tid' => $this->t('The term ID.'),
|
||||
'vid' => $this->t('Existing term VID'),
|
||||
'name' => $this->t('The name of the term.'),
|
||||
'description' => $this->t('The term description.'),
|
||||
'weight' => $this->t('Weight'),
|
||||
'parent' => $this->t("The Drupal term IDs of the term's parents."),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Find parents for this row.
|
||||
$parents = $this->select('term_hierarchy', 'th')
|
||||
->fields('th', array('parent', 'tid'))
|
||||
->condition('tid', $row->getSourceProperty('tid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('parent', $parents);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\TermNode.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Source returning tids from the term_node table for the current revision.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_term_node",
|
||||
* source_provider = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class TermNode extends DrupalSqlBase implements SourceEntityInterface {
|
||||
|
||||
/**
|
||||
* The join options between the node and the term node table.
|
||||
*/
|
||||
const JOIN = 'tn.vid = n.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('term_node', 'tn')
|
||||
// @todo: working, but not is there support for distinct() in FakeSelect?
|
||||
->distinct()
|
||||
->fields('tn', array('nid', 'vid'))
|
||||
->fields('n', array('type'));
|
||||
// Because this is an inner join it enforces the current revision.
|
||||
$query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'nid' => $this->t('The node revision ID.'),
|
||||
'vid' => $this->t('The node revision ID.'),
|
||||
'tid' => $this->t('The term ID.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Select the terms belonging to the revision selected.
|
||||
$query = $this->select('term_node', 'tn')
|
||||
->fields('tn', array('tid'))
|
||||
->condition('n.nid', $row->getSourceProperty('nid'));
|
||||
$query->join('node', 'n', static::JOIN);
|
||||
$query->innerJoin('term_data', 'td', 'td.tid = tn.tid AND td.vid = :vid', array(':vid' => $this->configuration['vid']));
|
||||
$row->setSourceProperty('tid', $query->execute()->fetchCol());
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'tn';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'taxonomy_term';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\TermNodeRevision.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Source returning tids from the term_node table for the non-current revision.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_term_node_revision"
|
||||
* )
|
||||
*/
|
||||
class TermNodeRevision extends TermNode {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
const JOIN = 'tn.nid = n.nid AND tn.vid != n.vid';
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Upload.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 upload source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_upload",
|
||||
* source_provider = "upload"
|
||||
* )
|
||||
*/
|
||||
class Upload extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The join options between the node and the upload table.
|
||||
*/
|
||||
const JOIN = 'n.nid = u.nid AND n.vid = u.vid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('upload', 'u')
|
||||
->distinct()
|
||||
->fields('u', array('nid', 'vid'));
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$query->addField('n', 'type');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$query = $this->select('upload', 'u')
|
||||
->fields('u', array('fid', 'description', 'list'))
|
||||
->condition('u.nid', $row->getSourceProperty('nid'))
|
||||
->orderBy('u.weight');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$row->setSourceProperty('upload', $query->execute()->fetchAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'fid' => $this->t('The file Id.'),
|
||||
'nid' => $this->t('The node Id.'),
|
||||
'vid' => $this->t('The version Id.'),
|
||||
'type' => $this->t('The node type'),
|
||||
'description' => $this->t('The file description.'),
|
||||
'list' => $this->t('Whether the list should be visible on the node page.'),
|
||||
'weight' => $this->t('The file weight.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'u';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UploadInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 upload instance source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_upload_instance",
|
||||
* source_provider = "upload"
|
||||
* )
|
||||
*/
|
||||
class UploadInstance extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$prefix = 'upload';
|
||||
$node_types = $this->getDatabase()->query('SELECT type FROM {node_type}')->fetchCol();
|
||||
foreach ($node_types as $node_type) {
|
||||
$variables[] = $prefix . '_' . $node_type;
|
||||
}
|
||||
|
||||
$max_filesize = $this->variableGet('upload_uploadsize_default', 1);
|
||||
$max_filesize = $max_filesize ? $max_filesize . 'MB' : '';
|
||||
$file_extensions = $this->variableGet('upload_extensions_default', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
|
||||
$return = array();
|
||||
$values = $this->getDatabase()->query('SELECT name, value FROM {variable} WHERE name IN ( :name[] )', array(':name[]' => $variables))->fetchAllKeyed();
|
||||
foreach ($node_types as $node_type) {
|
||||
$name = $prefix . '_' . $node_type;
|
||||
if (isset($values[$name])) {
|
||||
$enabled = unserialize($values[$name]);
|
||||
if ($enabled) {
|
||||
$return[$node_type]['node_type'] = $node_type;
|
||||
$return[$node_type]['max_filesize'] = $max_filesize;
|
||||
$return[$node_type]['file_extensions'] = $file_extensions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new \ArrayIterator($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'node_type' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Nothing needed here.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'node_type' => $this->t('Node type'),
|
||||
'max_filesize' => $this->t('Max filesize'),
|
||||
'file_extensions' => $this->t('File extensions'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UrlAlias.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 url aliases source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_url_alias"
|
||||
* )
|
||||
*/
|
||||
class UrlAlias extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('url_alias', 'ua')
|
||||
->fields('ua', array('pid', 'src', 'dst', 'language'));
|
||||
$query->orderBy('pid');
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'pid' => $this->t('The numeric identifier of the path alias.'),
|
||||
'src' => $this->t('The internal path.'),
|
||||
'dst' => $this->t('The user set path alias.'),
|
||||
'language' => $this->t('The language code of the url alias.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['pid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\User.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\SourceEntityInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 user source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user"
|
||||
* )
|
||||
*/
|
||||
class User extends DrupalSqlBase implements SourceEntityInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('users', 'u')
|
||||
->fields('u', array_keys($this->baseFields()))
|
||||
->condition('uid', 1, '>');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = $this->baseFields();
|
||||
|
||||
// Add roles field.
|
||||
$fields['roles'] = $this->t('Roles');
|
||||
|
||||
// Profile fields.
|
||||
if ($this->moduleExists('profile')) {
|
||||
$fields += $this->select('profile_fields', 'pf')
|
||||
->fields('pf', array('name', 'title'))
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// User roles.
|
||||
$roles = $this->select('users_roles', 'ur')
|
||||
->fields('ur', array('rid'))
|
||||
->condition('ur.uid', $row->getSourceProperty('uid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('roles', $roles);
|
||||
|
||||
// We are adding here the Event contributed module column.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($row->hasSourceProperty('timezone_id') && $row->getSourceProperty('timezone_id')) {
|
||||
if ($this->getDatabase()->schema()->tableExists('event_timezones')) {
|
||||
$event_timezone = $this->select('event_timezones', 'e')
|
||||
->fields('e', array('name'))
|
||||
->condition('e.timezone', $row->getSourceProperty('timezone_id'))
|
||||
->execute()
|
||||
->fetchField();
|
||||
if ($event_timezone) {
|
||||
$row->setSourceProperty('event_timezone', $event_timezone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unserialize Data.
|
||||
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'uid' => array(
|
||||
'type' => 'integer',
|
||||
'alias' => 'u',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user base fields to be migrated.
|
||||
*
|
||||
* @return array
|
||||
* Associative array having field name as key and description as value.
|
||||
*/
|
||||
protected function baseFields() {
|
||||
$fields = array(
|
||||
'uid' => $this->t('User ID'),
|
||||
'name' => $this->t('Username'),
|
||||
'pass' => $this->t('Password'),
|
||||
'mail' => $this->t('Email address'),
|
||||
'signature' => $this->t('Signature'),
|
||||
'signature_format' => $this->t('Signature format'),
|
||||
'created' => $this->t('Registered timestamp'),
|
||||
'access' => $this->t('Last access timestamp'),
|
||||
'login' => $this->t('Last login timestamp'),
|
||||
'status' => $this->t('Status'),
|
||||
'timezone' => $this->t('Timezone'),
|
||||
'language' => $this->t('Language'),
|
||||
'picture' => $this->t('Picture'),
|
||||
'init' => $this->t('Init'),
|
||||
'data' => $this->t('User data'),
|
||||
);
|
||||
|
||||
// Possible field added by Date contributed module.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($this->getDatabase()->schema()->fieldExists('users', 'timezone_name')) {
|
||||
$fields['timezone_name'] = $this->t('Timezone (Date)');
|
||||
}
|
||||
|
||||
// Possible field added by Event contributed module.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($this->getDatabase()->schema()->fieldExists('users', 'timezone_id')) {
|
||||
$fields['timezone_id'] = $this->t('Timezone (Event)');
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundleMigrationRequired() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityTypeId() {
|
||||
return 'user';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPicture.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 user picture source from database.
|
||||
*
|
||||
* @todo Support default picture?
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_picture"
|
||||
* )
|
||||
*/
|
||||
class UserPicture extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('users', 'u')
|
||||
->condition('picture', '', '<>')
|
||||
->fields('u', array('uid', 'access', 'picture'))
|
||||
->orderBy('access');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'uid' => 'Primary Key: Unique user ID.',
|
||||
'access' => 'Timestamp for previous time user accessed the site.',
|
||||
'picture' => "Path to the user's uploaded picture.",
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['uid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPictureFile.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 user picture source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_picture_file"
|
||||
* )
|
||||
*/
|
||||
class UserPictureFile extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The file directory path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filePath;
|
||||
|
||||
/**
|
||||
* The temporary file path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFilePath;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('users', 'u')
|
||||
->condition('picture', '', '<>')
|
||||
->fields('u', array('uid', 'picture'));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function initializeIterator() {
|
||||
$site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
|
||||
$this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
|
||||
$this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
$row->setSourceProperty('filename', basename($row->getSourceProperty('picture')));
|
||||
$row->setSourceProperty('file_directory_path', $this->filePath);
|
||||
$row->setSourceProperty('temp_directory_path', $this->tempFilePath);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'picture' => "Path to the user's uploaded picture.",
|
||||
'filename' => 'The picture filename.',
|
||||
);
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['uid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\UserPictureInstance.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 user picture field instance source.
|
||||
*
|
||||
* @todo Support default picture?
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_user_picture_instance"
|
||||
* )
|
||||
*/
|
||||
class UserPictureInstance extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function initializeIterator() {
|
||||
return new \ArrayIterator(array(
|
||||
array(
|
||||
'id' => '',
|
||||
'file_directory' => $this->variableGet('user_picture_path', 'pictures'),
|
||||
'max_filesize' => $this->variableGet('user_picture_file_size', '30') . 'KB',
|
||||
'max_resolution' => $this->variableGet('user_picture_dimensions', '85x85'),
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'file_directory' => 'The directory to store images..',
|
||||
'max_filesize' => 'The maximum allowed file size in KBs.',
|
||||
'max_resolution' => "The maximum resolution.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['id']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ViewMode.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* The view mode source.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_view_mode",
|
||||
* source_provider = "content"
|
||||
* )
|
||||
*/
|
||||
class ViewMode extends ViewModeBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$rows = array();
|
||||
$result = $this->prepareQuery()->execute();
|
||||
while ($field_row = $result->fetchAssoc()) {
|
||||
$field_row['display_settings'] = unserialize($field_row['display_settings']);
|
||||
foreach ($this->getViewModes() as $view_mode) {
|
||||
if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
|
||||
if (!isset($rows[$view_mode])) {
|
||||
$rows[$view_mode]['entity_type'] = 'node';
|
||||
$rows[$view_mode]['view_mode'] = $view_mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new \ArrayIterator($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('content_node_field_instance', 'cnfi')
|
||||
->fields('cnfi', array(
|
||||
'display_settings',
|
||||
));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'display_settings' => $this->t('Serialize data with display settings.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['view_mode']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function calculateDependencies() {
|
||||
$this->dependencies = parent::calculateDependencies();
|
||||
if (isset($this->configuration['constants']['targetEntityType'])) {
|
||||
$this->addDependency('module', $this->entityManager->getDefinition($this->configuration['constants']['targetEntityType'])->getProvider());
|
||||
}
|
||||
return $this->dependencies;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\ViewModeBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* A base class for migrations that require view mode info.
|
||||
*/
|
||||
abstract class ViewModeBase extends DrupalSqlBase {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return count($this->initializeIterator());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of D6 view modes.
|
||||
*
|
||||
* Drupal 6 supported the following view modes.
|
||||
* NODE_BUILD_NORMAL = 0
|
||||
* NODE_BUILD_PREVIEW = 1
|
||||
* NODE_BUILD_SEARCH_INDEX = 2
|
||||
* NODE_BUILD_SEARCH_RESULT = 3
|
||||
* NODE_BUILD_RSS = 4
|
||||
* NODE_BUILD_PRINT = 5
|
||||
* teaser
|
||||
* full
|
||||
*
|
||||
* @return array
|
||||
* The view mode names.
|
||||
*/
|
||||
public function getViewModes() {
|
||||
return array(
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
'teaser',
|
||||
'full',
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\Vocabulary.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Drupal 6 vocabularies source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_taxonomy_vocabulary",
|
||||
* source_provider = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class Vocabulary extends VocabularyBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// Find node types for this row.
|
||||
$node_types = $this->select('vocabulary_node_types', 'nt')
|
||||
->fields('nt', array('type', 'vid'))
|
||||
->condition('vid', $row->getSourceProperty('vid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('node_types', $node_types);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\VocabularyBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 vocabularies source base.
|
||||
*/
|
||||
abstract class VocabularyBase extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('vocabulary', 'v')
|
||||
->fields('v', array(
|
||||
'vid',
|
||||
'name',
|
||||
'description',
|
||||
'help',
|
||||
'relations',
|
||||
'hierarchy',
|
||||
'multiple',
|
||||
'required',
|
||||
'tags',
|
||||
'module',
|
||||
'weight',
|
||||
));
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'vid' => $this->t('The vocabulary ID.'),
|
||||
'name' => $this->t('The name of the vocabulary.'),
|
||||
'description' => $this->t('The description of the vocabulary.'),
|
||||
'help' => $this->t('Help text to display for the vocabulary.'),
|
||||
'relations' => $this->t('Whether or not related terms are enabled within the vocabulary. (0 = disabled, 1 = enabled)'),
|
||||
'hierarchy' => $this->t('The type of hierarchy allowed within the vocabulary. (0 = disabled, 1 = single, 2 = multiple)'),
|
||||
'multiple' => $this->t('Whether or not multiple terms from this vocabulary may be assigned to a node. (0 = disabled, 1 = enabled)'),
|
||||
'required' => $this->t('Whether or not terms are required for nodes using this vocabulary. (0 = disabled, 1 = enabled)'),
|
||||
'tags' => $this->t('Whether or not free tagging is enabled for the vocabulary. (0 = disabled, 1 = enabled)'),
|
||||
'weight' => $this->t('The weight of the vocabulary in relation to other vocabularies.'),
|
||||
'parents' => $this->t("The Drupal term IDs of the term's parents."),
|
||||
'node_types' => $this->t('The names of the node types the vocabulary may be used with.'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Plugin\migrate\source\d6\VocabularyPerType.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Gets all the vocabularies based on the node types that have Taxonomy enabled.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_taxonomy_vocabulary_per_type",
|
||||
* source_provider = "taxonomy"
|
||||
* )
|
||||
*/
|
||||
class VocabularyPerType extends Vocabulary {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = parent::query();
|
||||
$query->fields('nt', array(
|
||||
'type',
|
||||
));
|
||||
$query->join('vocabulary_node_types', 'nt', 'v.vid = nt.vid');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['vid']['type'] = 'integer';
|
||||
$ids['vid']['alias'] = 'nt';
|
||||
$ids['type']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Dump;
|
||||
|
||||
use Drupal\Core\Database\Connection;
|
||||
|
||||
/**
|
||||
* Base class for the dump classes.
|
||||
*/
|
||||
class DrupalDumpBase {
|
||||
|
||||
/**
|
||||
* The database connection.
|
||||
*
|
||||
* @var \Drupal\Core\Database\Connection
|
||||
*/
|
||||
protected $database;
|
||||
|
||||
/**
|
||||
* An array of tables that have already been created.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $migrateTables;
|
||||
|
||||
/**
|
||||
* Sample database schema and values.
|
||||
*
|
||||
* @param \Drupal\Core\Database\Connection $database
|
||||
* The database connection.
|
||||
*/
|
||||
public function __construct(Connection $database) {
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new table from a Drupal table definition if it doesn't exist.
|
||||
*
|
||||
* @param string $name
|
||||
* The name of the table to create.
|
||||
* @param array $table
|
||||
* A Schema API table definition array.
|
||||
*/
|
||||
protected function createTable($name, array $table) {
|
||||
// This must be on the database connection to be shared among classes.
|
||||
if (empty($this->database->migrateTables[$name])) {
|
||||
$this->database->migrateTables[$name] = TRUE;
|
||||
$this->database->schema()->createTable($name, $table);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\MigrateDrupalTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests;
|
||||
|
||||
use Drupal\migrate\Tests\MigrateTestBase;
|
||||
|
||||
/**
|
||||
* Base class for Drupal migration tests.
|
||||
*/
|
||||
abstract class MigrateDrupalTestBase extends MigrateTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'user', 'field', 'migrate_drupal', 'options');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->loadDumps([$this->getDumpDirectory() . '/System.php']);
|
||||
|
||||
$this->installEntitySchema('user');
|
||||
$this->installConfig(['migrate_drupal', 'system']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the path to the dump directory.
|
||||
*
|
||||
* @return string
|
||||
* A string that represents the dump directory path.
|
||||
*/
|
||||
protected function getDumpDirectory() {
|
||||
return __DIR__ . '/Table';
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\MigrateFullDrupalTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Config\ExtensionInstallStorage;
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Config\StorageInterface;
|
||||
use Drupal\migrate\MigrateExecutable;
|
||||
use Drupal\simpletest\TestBase;
|
||||
|
||||
/**
|
||||
* Test helper for running a complete Drupal migration.
|
||||
*/
|
||||
abstract class MigrateFullDrupalTestBase extends MigrateDrupalTestBase {
|
||||
|
||||
/**
|
||||
* Get the dump classes required for this migration test.
|
||||
*
|
||||
* @return array
|
||||
* The list of files containing dumps.
|
||||
*/
|
||||
protected abstract function getDumps();
|
||||
|
||||
/**
|
||||
* Get the test classes that needs to be run for this test.
|
||||
*
|
||||
* @return array
|
||||
* The list of test fully-classified class names.
|
||||
*/
|
||||
protected abstract function getTestClassesList();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown() {
|
||||
// Move the results of every class under ours. This is solely for
|
||||
// reporting, the filename will guide developers.
|
||||
self::getDatabaseConnection()
|
||||
->update('simpletest')
|
||||
->fields(array('test_class' => get_class($this)))
|
||||
->condition('test_id', $this->testId)
|
||||
->execute();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test the complete Drupal migration.
|
||||
*/
|
||||
public function testDrupal() {
|
||||
$dumps = $this->getDumps();
|
||||
$this->loadDumps($dumps);
|
||||
|
||||
$classes = $this->getTestClassesList();
|
||||
$extension_install_storage = new ExtensionInstallStorage(\Drupal::service('config.storage'), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE);
|
||||
foreach ($classes as $class) {
|
||||
if (is_subclass_of($class, '\Drupal\migrate\Tests\MigrateDumpAlterInterface')) {
|
||||
$class::migrateDumpAlter($this);
|
||||
}
|
||||
}
|
||||
|
||||
// Run every migration in the order specified by the storage controller.
|
||||
foreach (entity_load_multiple('migration', static::$migrations) as $migration) {
|
||||
(new MigrateExecutable($migration, $this))->import();
|
||||
|
||||
// Ensure that the default migration has the correct dependencies.
|
||||
list($base_name, ) = explode(':', $migration->id(), 2);
|
||||
$default_configuration = $extension_install_storage->read('migrate.migration.' . $base_name);
|
||||
$default_dependencies = isset($default_configuration['dependencies']) ? $default_configuration['dependencies'] : [];
|
||||
$this->assertEqual($default_dependencies, $migration->getDependencies(), SafeMarkup::format('Dependencies in @id match after installing. Default configuration @first is equal to active configuration @second.', array(
|
||||
'@id' => $migration->id(),
|
||||
'@first' => var_export($default_dependencies, TRUE),
|
||||
'@second' => var_export($migration->getDependencies(), TRUE)
|
||||
)));
|
||||
}
|
||||
foreach ($classes as $class) {
|
||||
$test_object = new $class($this->testId);
|
||||
$test_object->databasePrefix = $this->databasePrefix;
|
||||
$test_object->container = $this->container;
|
||||
// run() does a lot of setup and tear down work which we don't need:
|
||||
// it would setup a new database connection and wouldn't find the
|
||||
// Drupal dump. Also by skipping the setUp() methods there are no id
|
||||
// mappings or entities prepared. The tests run against solely migrated
|
||||
// data.
|
||||
foreach (get_class_methods($test_object) as $method) {
|
||||
if (strtolower(substr($method, 0, 4)) == 'test') {
|
||||
// Insert a fail record. This will be deleted on completion to ensure
|
||||
// that testing completed.
|
||||
$method_info = new \ReflectionMethod($class, $method);
|
||||
$caller = array(
|
||||
'file' => $method_info->getFileName(),
|
||||
'line' => $method_info->getStartLine(),
|
||||
'function' => $class . '->' . $method . '()',
|
||||
);
|
||||
$completion_check_id = TestBase::insertAssert($this->testId, $class, FALSE, 'The test did not complete due to a fatal error.', 'Completion check', $caller);
|
||||
// Run the test method.
|
||||
try {
|
||||
$test_object->$method();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$this->exceptionHandler($e);
|
||||
}
|
||||
// Remove the completion check record.
|
||||
TestBase::deleteAssert($completion_check_id);
|
||||
}
|
||||
}
|
||||
// Add the pass/fail/exception/debug results.
|
||||
foreach ($this->results as $key => &$value) {
|
||||
$value += $test_object->results[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\MigrateTableDumpTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests;
|
||||
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Validates the table dumps.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class MigrateTableDumpTest extends KernelTestBase {
|
||||
|
||||
protected function verifyDumpFiles($directory) {
|
||||
$tables = file_scan_directory($directory, '/.php$/');
|
||||
foreach ($tables as $table) {
|
||||
$contents = rtrim(file_get_contents($table->uri));
|
||||
$this->assertIdentical(substr($contents, -32), md5(substr($contents, 0, -33)), $table->uri);
|
||||
}
|
||||
}
|
||||
|
||||
public function testMigrateDrupal6TableDumps() {
|
||||
$this->verifyDumpFiles(__DIR__ . '/Table/d6');
|
||||
}
|
||||
|
||||
public function testMigrateDrupal7TableDumps() {
|
||||
$this->verifyDumpFiles(__DIR__ . '/Table/d7');
|
||||
}
|
||||
|
||||
}
|
64
core/modules/migrate_drupal/src/Tests/Table/d6/Access.php
Normal file
64
core/modules/migrate_drupal/src/Tests/Table/d6/Access.php
Normal file
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Access.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the access table.
|
||||
*/
|
||||
class Access extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("access", array(
|
||||
'primary key' => array(
|
||||
'aid',
|
||||
),
|
||||
'fields' => array(
|
||||
'aid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
),
|
||||
'mask' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'type' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'status' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("access")->fields(array(
|
||||
'aid',
|
||||
'mask',
|
||||
'type',
|
||||
'status',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#131cb9eb08548867ec92c3373ac67a42
|
137
core/modules/migrate_drupal/src/Tests/Table/d6/Actions.php
Normal file
137
core/modules/migrate_drupal/src/Tests/Table/d6/Actions.php
Normal file
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Actions.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the actions table.
|
||||
*/
|
||||
class Actions extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("actions", array(
|
||||
'primary key' => array(
|
||||
'aid',
|
||||
),
|
||||
'fields' => array(
|
||||
'aid' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '0',
|
||||
),
|
||||
'type' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '32',
|
||||
'default' => '',
|
||||
),
|
||||
'callback' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'parameters' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'length' => 100,
|
||||
),
|
||||
'description' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("actions")->fields(array(
|
||||
'aid',
|
||||
'type',
|
||||
'callback',
|
||||
'parameters',
|
||||
'description',
|
||||
))
|
||||
->values(array(
|
||||
'aid' => 'comment_publish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'comment_publish_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Publish comment',
|
||||
))->values(array(
|
||||
'aid' => 'comment_unpublish_action',
|
||||
'type' => 'comment',
|
||||
'callback' => 'comment_unpublish_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Unpublish comment',
|
||||
))->values(array(
|
||||
'aid' => 'node_make_sticky_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_make_sticky_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Make post sticky',
|
||||
))->values(array(
|
||||
'aid' => 'node_make_unsticky_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_make_unsticky_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Make post unsticky',
|
||||
))->values(array(
|
||||
'aid' => 'node_promote_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_promote_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Promote post to front page',
|
||||
))->values(array(
|
||||
'aid' => 'node_publish_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_publish_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Publish post',
|
||||
))->values(array(
|
||||
'aid' => 'node_save_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_save_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Save post',
|
||||
))->values(array(
|
||||
'aid' => 'node_unpromote_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_unpromote_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Remove post from front page',
|
||||
))->values(array(
|
||||
'aid' => 'node_unpublish_action',
|
||||
'type' => 'node',
|
||||
'callback' => 'node_unpublish_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Unpublish post',
|
||||
))->values(array(
|
||||
'aid' => 'user_block_ip_action',
|
||||
'type' => 'user',
|
||||
'callback' => 'user_block_ip_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Ban IP address of current user',
|
||||
))->values(array(
|
||||
'aid' => 'user_block_user_action',
|
||||
'type' => 'user',
|
||||
'callback' => 'user_block_user_action',
|
||||
'parameters' => '',
|
||||
'description' => 'Block current user',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#31f375c70c6a362432e25e1256101076
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\ActionsAid.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the actions_aid table.
|
||||
*/
|
||||
class ActionsAid extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("actions_aid", array(
|
||||
'primary key' => array(
|
||||
'aid',
|
||||
),
|
||||
'fields' => array(
|
||||
'aid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("actions_aid")->fields(array(
|
||||
'aid',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#a58e383f81c657ac36eabc980e148fbd
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\AggregatorCategory.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the aggregator_category table.
|
||||
*/
|
||||
class AggregatorCategory extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("aggregator_category", array(
|
||||
'primary key' => array(
|
||||
'cid',
|
||||
),
|
||||
'fields' => array(
|
||||
'cid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'description' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'length' => 100,
|
||||
),
|
||||
'block' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("aggregator_category")->fields(array(
|
||||
'cid',
|
||||
'title',
|
||||
'description',
|
||||
'block',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#836a3ecaf192c09b996431f0c4b71fe6
|
|
@ -0,0 +1,123 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\AggregatorFeed.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the aggregator_feed table.
|
||||
*/
|
||||
class AggregatorFeed extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("aggregator_feed", array(
|
||||
'primary key' => array(
|
||||
'fid',
|
||||
),
|
||||
'fields' => array(
|
||||
'fid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'url' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'refresh' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'checked' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'link' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'description' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'length' => 100,
|
||||
),
|
||||
'image' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'length' => 100,
|
||||
),
|
||||
'etag' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'modified' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'block' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("aggregator_feed")->fields(array(
|
||||
'fid',
|
||||
'title',
|
||||
'url',
|
||||
'refresh',
|
||||
'checked',
|
||||
'link',
|
||||
'description',
|
||||
'image',
|
||||
'etag',
|
||||
'modified',
|
||||
'block',
|
||||
))
|
||||
->values(array(
|
||||
'fid' => '5',
|
||||
'title' => 'Know Your Meme',
|
||||
'url' => 'http://knowyourmeme.com/newsfeed.rss',
|
||||
'refresh' => '900',
|
||||
'checked' => '1387659487',
|
||||
'link' => 'http://knowyourmeme.com',
|
||||
'description' => 'New items added to the News Feed',
|
||||
'image' => 'http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png',
|
||||
'etag' => '"213cc1365b96c310e92053c5551f0504"',
|
||||
'modified' => '0',
|
||||
'block' => '5',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#662f4470777c1bda31d407bb5ba21346
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\AggregatorItem.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the aggregator_item table.
|
||||
*/
|
||||
class AggregatorItem extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("aggregator_item", array(
|
||||
'primary key' => array(
|
||||
'iid',
|
||||
),
|
||||
'fields' => array(
|
||||
'iid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
),
|
||||
'fid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'link' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'author' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'description' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'length' => 100,
|
||||
),
|
||||
'timestamp' => array(
|
||||
'type' => 'int',
|
||||
'not null' => FALSE,
|
||||
'length' => '11',
|
||||
),
|
||||
'guid' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => FALSE,
|
||||
'length' => '255',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("aggregator_item")->fields(array(
|
||||
'iid',
|
||||
'fid',
|
||||
'title',
|
||||
'link',
|
||||
'author',
|
||||
'description',
|
||||
'timestamp',
|
||||
'guid',
|
||||
))
|
||||
->values(array(
|
||||
'iid' => '1',
|
||||
'fid' => '5',
|
||||
'title' => 'This (three) weeks in Drupal Core - January 10th 2014',
|
||||
'link' => 'https://groups.drupal.org/node/395218',
|
||||
'author' => 'larowlan',
|
||||
'description' => "<h2 id='new'>What's new with Drupal 8?</h2>",
|
||||
'timestamp' => '1389297196',
|
||||
'guid' => '395218 at https://groups.drupal.org',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#70ab48fd0f8a2fca2f51df61fdef0443
|
65
core/modules/migrate_drupal/src/Tests/Table/d6/Authmap.php
Normal file
65
core/modules/migrate_drupal/src/Tests/Table/d6/Authmap.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Authmap.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the authmap table.
|
||||
*/
|
||||
class Authmap extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("authmap", array(
|
||||
'primary key' => array(
|
||||
'aid',
|
||||
),
|
||||
'fields' => array(
|
||||
'aid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'uid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'authname' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '128',
|
||||
'default' => '',
|
||||
),
|
||||
'module' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '128',
|
||||
'default' => '',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("authmap")->fields(array(
|
||||
'aid',
|
||||
'uid',
|
||||
'authname',
|
||||
'module',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#265fd37faf94406aa5ae64f834c0c09c
|
62
core/modules/migrate_drupal/src/Tests/Table/d6/Batch.php
Normal file
62
core/modules/migrate_drupal/src/Tests/Table/d6/Batch.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Batch.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the batch table.
|
||||
*/
|
||||
class Batch extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("batch", array(
|
||||
'primary key' => array(
|
||||
'bid',
|
||||
),
|
||||
'fields' => array(
|
||||
'bid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'token' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '64',
|
||||
),
|
||||
'timestamp' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
),
|
||||
'batch' => array(
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'length' => 100,
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("batch")->fields(array(
|
||||
'bid',
|
||||
'token',
|
||||
'timestamp',
|
||||
'batch',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#7e3b35a2ee513385c7a63500e1a588c6
|
406
core/modules/migrate_drupal/src/Tests/Table/d6/Blocks.php
Normal file
406
core/modules/migrate_drupal/src/Tests/Table/d6/Blocks.php
Normal file
|
@ -0,0 +1,406 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Blocks.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the blocks table.
|
||||
*/
|
||||
class Blocks extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("blocks", array(
|
||||
'primary key' => array(
|
||||
'bid',
|
||||
),
|
||||
'fields' => array(
|
||||
'bid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
),
|
||||
'module' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '64',
|
||||
'default' => '',
|
||||
),
|
||||
'delta' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '32',
|
||||
'default' => '0',
|
||||
),
|
||||
'theme' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '64',
|
||||
'default' => '',
|
||||
),
|
||||
'status' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'weight' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'region' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '64',
|
||||
'default' => '',
|
||||
),
|
||||
'custom' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'throttle' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'visibility' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'pages' => array(
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
'length' => 100,
|
||||
),
|
||||
'title' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '64',
|
||||
'default' => '',
|
||||
),
|
||||
'cache' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '1',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("blocks")->fields(array(
|
||||
'bid',
|
||||
'module',
|
||||
'delta',
|
||||
'theme',
|
||||
'status',
|
||||
'weight',
|
||||
'region',
|
||||
'custom',
|
||||
'throttle',
|
||||
'visibility',
|
||||
'pages',
|
||||
'title',
|
||||
'cache',
|
||||
))
|
||||
->values(array(
|
||||
'bid' => '1',
|
||||
'module' => 'user',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '0',
|
||||
'region' => 'left',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '2',
|
||||
'module' => 'user',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '0',
|
||||
'region' => 'left',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '3',
|
||||
'module' => 'system',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '-5',
|
||||
'region' => 'footer',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => 'node/1',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '4',
|
||||
'module' => 'comment',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-9',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '1',
|
||||
))->values(array(
|
||||
'bid' => '5',
|
||||
'module' => 'menu',
|
||||
'delta' => 'primary-links',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '-5',
|
||||
'region' => 'header',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '6',
|
||||
'module' => 'menu',
|
||||
'delta' => 'secondary-links',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-8',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '7',
|
||||
'module' => 'node',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-7',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '8',
|
||||
'module' => 'user',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '-9',
|
||||
'region' => 'right',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '1',
|
||||
))->values(array(
|
||||
'bid' => '9',
|
||||
'module' => 'user',
|
||||
'delta' => '3',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '-6',
|
||||
'region' => 'right',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '10',
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => '1',
|
||||
'weight' => '0',
|
||||
'region' => 'content',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '1',
|
||||
'pages' => '<front>',
|
||||
'title' => 'Static Block',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '11',
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'bluemarine',
|
||||
'status' => '1',
|
||||
'weight' => '-4',
|
||||
'region' => 'right',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '1',
|
||||
'pages' => 'node',
|
||||
'title' => 'Another Static Block',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '12',
|
||||
'module' => 'block',
|
||||
'delta' => '1',
|
||||
'theme' => 'test_theme',
|
||||
'status' => '1',
|
||||
'weight' => '-7',
|
||||
'region' => 'right',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '13',
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'test_theme',
|
||||
'status' => '1',
|
||||
'weight' => '-2',
|
||||
'region' => 'left',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '14',
|
||||
'module' => 'aggregator',
|
||||
'delta' => 'feed-5',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-2',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '1',
|
||||
))->values(array(
|
||||
'bid' => '15',
|
||||
'module' => 'block',
|
||||
'delta' => '2',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '1',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '-1',
|
||||
))->values(array(
|
||||
'bid' => '16',
|
||||
'module' => 'profile',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-5',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '5',
|
||||
))->values(array(
|
||||
'bid' => '17',
|
||||
'module' => 'event',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-3',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '1',
|
||||
))->values(array(
|
||||
'bid' => '18',
|
||||
'module' => 'event',
|
||||
'delta' => '1',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '0',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '1',
|
||||
))->values(array(
|
||||
'bid' => '19',
|
||||
'module' => 'event',
|
||||
'delta' => 'event-upcoming-event',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-1',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '1',
|
||||
))->values(array(
|
||||
'bid' => '20',
|
||||
'module' => 'book',
|
||||
'delta' => '0',
|
||||
'theme' => 'garland',
|
||||
'status' => '0',
|
||||
'weight' => '-4',
|
||||
'region' => '',
|
||||
'custom' => '0',
|
||||
'throttle' => '0',
|
||||
'visibility' => '0',
|
||||
'pages' => '',
|
||||
'title' => '',
|
||||
'cache' => '5',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#aecc8e1067d73824c43bfaf26f9ebf8c
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\BlocksRoles.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the blocks_roles table.
|
||||
*/
|
||||
class BlocksRoles extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("blocks_roles", array(
|
||||
'primary key' => array(
|
||||
'module',
|
||||
'delta',
|
||||
'rid',
|
||||
),
|
||||
'fields' => array(
|
||||
'module' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '64',
|
||||
),
|
||||
'delta' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '32',
|
||||
),
|
||||
'rid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("blocks_roles")->fields(array(
|
||||
'module',
|
||||
'delta',
|
||||
'rid',
|
||||
))
|
||||
->values(array(
|
||||
'module' => 'user',
|
||||
'delta' => '2',
|
||||
'rid' => '2',
|
||||
))->values(array(
|
||||
'module' => 'user',
|
||||
'delta' => '3',
|
||||
'rid' => '3',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#41ed39f4e800ee584535def863835a80
|
81
core/modules/migrate_drupal/src/Tests/Table/d6/Book.php
Normal file
81
core/modules/migrate_drupal/src/Tests/Table/d6/Book.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Book.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the book table.
|
||||
*/
|
||||
class Book extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("book", array(
|
||||
'primary key' => array(
|
||||
'mlid',
|
||||
),
|
||||
'fields' => array(
|
||||
'mlid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'default' => '0',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'nid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'default' => '0',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'bid' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'default' => '0',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("book")->fields(array(
|
||||
'mlid',
|
||||
'nid',
|
||||
'bid',
|
||||
))
|
||||
->values(array(
|
||||
'mlid' => '1',
|
||||
'nid' => '4',
|
||||
'bid' => '4',
|
||||
))->values(array(
|
||||
'mlid' => '2',
|
||||
'nid' => '5',
|
||||
'bid' => '4',
|
||||
))->values(array(
|
||||
'mlid' => '3',
|
||||
'nid' => '6',
|
||||
'bid' => '4',
|
||||
))->values(array(
|
||||
'mlid' => '4',
|
||||
'nid' => '7',
|
||||
'bid' => '4',
|
||||
))->values(array(
|
||||
'mlid' => '5',
|
||||
'nid' => '8',
|
||||
'bid' => '8',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#6ddf63f063b1bfa617a96764d859a0f1
|
74
core/modules/migrate_drupal/src/Tests/Table/d6/Boxes.php
Normal file
74
core/modules/migrate_drupal/src/Tests/Table/d6/Boxes.php
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Boxes.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the boxes table.
|
||||
*/
|
||||
class Boxes extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("boxes", array(
|
||||
'primary key' => array(
|
||||
'bid',
|
||||
),
|
||||
'fields' => array(
|
||||
'bid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'length' => '10',
|
||||
'unsigned' => TRUE,
|
||||
),
|
||||
'body' => array(
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'length' => 100,
|
||||
),
|
||||
'info' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '128',
|
||||
'default' => '',
|
||||
),
|
||||
'format' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("boxes")->fields(array(
|
||||
'bid',
|
||||
'body',
|
||||
'info',
|
||||
'format',
|
||||
))
|
||||
->values(array(
|
||||
'bid' => '1',
|
||||
'body' => '<h3>My first custom block body</h3>',
|
||||
'info' => 'My block 1',
|
||||
'format' => '2',
|
||||
))->values(array(
|
||||
'bid' => '2',
|
||||
'body' => '<h3>My second custom block body</h3>',
|
||||
'info' => 'My block 2',
|
||||
'format' => '2',
|
||||
))->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#2210f6e6a50ddd9c00900cc7e54a5b43
|
77
core/modules/migrate_drupal/src/Tests/Table/d6/Cache.php
Normal file
77
core/modules/migrate_drupal/src/Tests/Table/d6/Cache.php
Normal file
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\Cache.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the cache table.
|
||||
*/
|
||||
class Cache extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("cache", array(
|
||||
'primary key' => array(
|
||||
'cid',
|
||||
),
|
||||
'fields' => array(
|
||||
'cid' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'data' => array(
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
'length' => 100,
|
||||
),
|
||||
'expire' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'created' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'headers' => array(
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'length' => 100,
|
||||
),
|
||||
'serialized' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("cache")->fields(array(
|
||||
'cid',
|
||||
'data',
|
||||
'expire',
|
||||
'created',
|
||||
'headers',
|
||||
'serialized',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#67029a22a76da3708c39edc1ea19e8da
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate_drupal\Tests\Table\d6\CacheBlock.
|
||||
*
|
||||
* THIS IS A GENERATED FILE. DO NOT EDIT.
|
||||
*
|
||||
* @see core/scripts/migrate-db.sh
|
||||
* @see https://www.drupal.org/sandbox/benjy/2405029
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate_drupal\Tests\Table\d6;
|
||||
|
||||
use Drupal\migrate_drupal\Tests\Dump\DrupalDumpBase;
|
||||
|
||||
/**
|
||||
* Generated file to represent the cache_block table.
|
||||
*/
|
||||
class CacheBlock extends DrupalDumpBase {
|
||||
|
||||
public function load() {
|
||||
$this->createTable("cache_block", array(
|
||||
'primary key' => array(
|
||||
'cid',
|
||||
),
|
||||
'fields' => array(
|
||||
'cid' => array(
|
||||
'type' => 'varchar',
|
||||
'not null' => TRUE,
|
||||
'length' => '255',
|
||||
'default' => '',
|
||||
),
|
||||
'data' => array(
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
'length' => 100,
|
||||
),
|
||||
'expire' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'created' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
'headers' => array(
|
||||
'type' => 'text',
|
||||
'not null' => FALSE,
|
||||
'length' => 100,
|
||||
),
|
||||
'serialized' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'length' => '11',
|
||||
'default' => '0',
|
||||
),
|
||||
),
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
$this->database->insert("cache_block")->fields(array(
|
||||
'cid',
|
||||
'data',
|
||||
'expire',
|
||||
'created',
|
||||
'headers',
|
||||
'serialized',
|
||||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
#a8cd855bd812efa861fb2b1b16a60c88
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue