upgrades core to 8.4.2
This commit is contained in:
@@ -7,8 +7,8 @@ package: Core (Experimental)
|
||||
dependencies:
|
||||
- migrate
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -56,9 +56,17 @@ function migrate_drupal_migration_plugins_alter(&$definitions) {
|
||||
$source_vid = $row->getSourceProperty('vid');
|
||||
$plugin_ids = ['d6_term_node:' . $source_vid, 'd6_term_node_revision:' . $source_vid];
|
||||
foreach ($plugin_ids as $plugin_id) {
|
||||
if (isset($definitions[$plugin_id])) {
|
||||
$definitions[$plugin_id]['process'][$row->getDestinationProperty('vid')] = 'tid';
|
||||
}
|
||||
// Match the field name derivation in d6_vocabulary_field.yml.
|
||||
$field_name = substr('field_' . $row->getDestinationProperty('vid'), 0, 32);
|
||||
|
||||
// The Forum module is expecting 'taxonomy_forums' as the field name
|
||||
// for the forum nodes. The 'forum_vocabulary' source property is
|
||||
// evaluated in Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
|
||||
// and is set to true if the vocabulary vid being migrated is the
|
||||
// same as the one in the 'forum_nav_vocabulary' variable on the
|
||||
// source site.
|
||||
$destination_vid = $row->getSourceProperty('forum_vocabulary') ? 'taxonomy_forums' : $field_name;
|
||||
$definitions[$plugin_id]['process'][$destination_vid] = 'tid';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Annotation;
|
||||
|
||||
@trigger_error('MigrateCckField is deprecated in Drupal 8.3.x and will be
|
||||
removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField
|
||||
instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('MigrateCckField is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Deprecated: Defines a cckfield plugin annotation object.
|
||||
@@ -14,6 +12,8 @@ instead.', E_USER_DEPRECATED);
|
||||
*
|
||||
* Plugin Namespace: Plugin\migrate\cckfield
|
||||
*
|
||||
* @see https://www.drupal.org/node/2751897
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class MigrateCckField extends MigrateField {
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
|
||||
namespace Drupal\migrate_drupal;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated in Drupal 8.1.x, will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\migrate_drupal\MigrationConfigurationTrait instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2873794
|
||||
*/
|
||||
trait MigrationCreationTrait {
|
||||
use MigrationConfigurationTrait;
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
@trigger_error('MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will
|
||||
be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField
|
||||
instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
@@ -13,6 +11,8 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Annotation\MigrateField instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2751897
|
||||
*/
|
||||
interface MigrateCckFieldInterface extends MigrateFieldInterface {
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
@trigger_error('MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will
|
||||
be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager
|
||||
instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Deprecated: Plugin manager for migrate field plugins.
|
||||
@@ -12,6 +10,8 @@ instead.', E_USER_DEPRECATED);
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2751897
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
class MigrateCckFieldPluginManager extends MigrateFieldPluginManager implements MigrateCckFieldPluginManagerInterface { }
|
||||
class MigrateCckFieldPluginManager extends MigrateFieldPluginManager implements MigrateCckFieldPluginManagerInterface {}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
@trigger_error('MigrateCckFieldPluginManagerInterface is deprecated in Drupal 8.3.x
|
||||
and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManagerInterface
|
||||
instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('MigrateCckFieldPluginManagerInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManagerInterface instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Provides an interface for cck field plugin manager.
|
||||
@@ -14,4 +12,4 @@ instead.', E_USER_DEPRECATED);
|
||||
*
|
||||
* @see https://www.drupal.org/node/2751897
|
||||
*/
|
||||
interface MigrateCckFieldPluginManagerInterface extends MigrateFieldPluginManagerInterface { }
|
||||
interface MigrateCckFieldPluginManagerInterface extends MigrateFieldPluginManagerInterface {}
|
||||
|
||||
@@ -43,6 +43,17 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
|
||||
*/
|
||||
public function processFieldFormatter(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Get the field formatter type from the source.
|
||||
*
|
||||
* @param \Drupal\migrate\Row $row
|
||||
* The field being migrated.
|
||||
*
|
||||
* @return string
|
||||
* The field formatter type.
|
||||
*/
|
||||
public function getFieldFormatterType(Row $row);
|
||||
|
||||
/**
|
||||
* Get a map between D6 formatters and D8 formatters for this field type.
|
||||
*
|
||||
@@ -53,6 +64,17 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
|
||||
*/
|
||||
public function getFieldFormatterMap();
|
||||
|
||||
/**
|
||||
* Get the field widget type from the source.
|
||||
*
|
||||
* @param \Drupal\migrate\Row $row
|
||||
* The field being migrated.
|
||||
*
|
||||
* @return string
|
||||
* The field widget type.
|
||||
*/
|
||||
public function getFieldWidgetType(Row $row);
|
||||
|
||||
/**
|
||||
* Get a map between D6 and D8 widgets for this field type.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@ use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* Plugin manager for migrate cckfield plugins.
|
||||
* Plugin manager for migrate field plugins.
|
||||
*
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
|
||||
* @see \Drupal\migrate\Annotation\MigrateField
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate;
|
||||
|
||||
@trigger_error('CckMigration is deprecated in Drupal 8.3.x and will be removed
|
||||
before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\FieldMigration
|
||||
instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('CckMigration is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\FieldMigration instead.', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Migration plugin class for migrations dealing with CCK field values.
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\migrate\FieldMigration instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2751897
|
||||
*/
|
||||
class CckMigration extends FieldMigration {
|
||||
|
||||
|
||||
@@ -140,25 +140,25 @@ class FieldMigration extends Migration implements ContainerFactoryPluginInterfac
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
|
||||
try {
|
||||
$plugin_id = $this->cckPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
$Manager = $this->cckPluginManager;
|
||||
$plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
$manager = $this->fieldPluginManager;
|
||||
}
|
||||
catch (PluginNotFoundException $ex) {
|
||||
try {
|
||||
$plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
$Manager = $this->fieldPluginManager;
|
||||
$plugin_id = $this->cckPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
$manager = $this->cckPluginManager;
|
||||
}
|
||||
catch (PluginNotFoundException $ex) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($this->processedFieldTypes[$field_type]) && $Manager->hasDefinition($plugin_id)) {
|
||||
if (!isset($this->processedFieldTypes[$field_type]) && $manager->hasDefinition($plugin_id)) {
|
||||
$this->processedFieldTypes[$field_type] = TRUE;
|
||||
// Allow the field plugin to alter the migration as necessary so that
|
||||
// it knows how to handle fields of this type.
|
||||
if (!isset($this->fieldPluginCache[$field_type])) {
|
||||
$this->fieldPluginCache[$field_type] = $Manager->createInstance($plugin_id, [], $this);
|
||||
$this->fieldPluginCache[$field_type] = $manager->createInstance($plugin_id, [], $this);
|
||||
}
|
||||
}
|
||||
$method = $this->pluginDefinition[static::PLUGIN_METHOD];
|
||||
|
||||
@@ -2,22 +2,23 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
|
||||
|
||||
@trigger_error('CckFieldPluginBase is deprecated in Drupal 8.3.x and will be
|
||||
be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase
|
||||
instead.', E_USER_DEPRECATED);
|
||||
@trigger_error('CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.', E_USER_DEPRECATED);
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
|
||||
|
||||
/**
|
||||
* The base class for all field plugins.
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2751897
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
abstract class CckFieldPluginBase extends FieldPluginBase {
|
||||
abstract class CckFieldPluginBase extends FieldPluginBase implements MigrateCckFieldInterface {
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field bundle migrations.
|
||||
|
||||
+2
-2
@@ -49,10 +49,10 @@ class EntityFieldStorageConfig extends BaseEntityFieldStorageConfig {
|
||||
* The list of bundles this entity type has.
|
||||
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
|
||||
* The language manager.
|
||||
* @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager
|
||||
* The field type plugin manager.
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The configuration factory.
|
||||
* @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, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, FieldTypePluginManagerInterface $field_type_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $config_factory, $field_type_plugin_manager);
|
||||
|
||||
@@ -45,6 +45,27 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterfa
|
||||
$migration->mergeProcessOfProperty('options/type', $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterType(Row $row) {
|
||||
return $row->getSourceProperty('formatter/type');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldWidgetType(Row $row) {
|
||||
return $row->getSourceProperty('widget/type');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -60,12 +81,28 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterfa
|
||||
*/
|
||||
public function processFieldFormatter(MigrationInterface $migration) {
|
||||
$process = [];
|
||||
|
||||
// Some migrate field plugin IDs are prefixed with 'd6_' or 'd7_'. Since the
|
||||
// plugin ID is used in the static map as the module name, we have to remove
|
||||
// this prefix from the plugin ID.
|
||||
$plugin_id = preg_replace('/d[67]_/', '', $this->pluginId);
|
||||
foreach ($this->getFieldFormatterMap() as $source_format => $destination_format) {
|
||||
$process[0]['map'][$this->pluginId][$source_format] = $destination_format;
|
||||
$process[0]['map'][$plugin_id][$source_format] = $destination_format;
|
||||
}
|
||||
$migration->mergeProcessOfProperty('options/type', $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'get',
|
||||
'source' => $field_name,
|
||||
];
|
||||
$migration->mergeProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -15,13 +15,6 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
*/
|
||||
class NodeReference extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -15,13 +15,6 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
*/
|
||||
class UserReference extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
@@ -94,14 +94,14 @@ abstract class DrupalSqlBase extends SqlBase implements ContainerFactoryPluginIn
|
||||
*/
|
||||
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']) {
|
||||
if (isset($this->pluginDefinition['source_module'])) {
|
||||
if ($this->moduleExists($this->pluginDefinition['source_module'])) {
|
||||
if (isset($this->pluginDefinition['minimum_schema_version']) && !$this->getModuleSchemaVersion($this->pluginDefinition['source_module']) < $this->pluginDefinition['minimum_schema_version']) {
|
||||
throw new RequirementsException('Required minimum schema version ' . $this->pluginDefinition['minimum_schema_version'], ['minimum_schema_version' => $this->pluginDefinition['minimum_schema_version']]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RequirementsException('The module ' . $this->pluginDefinition['source_provider'] . ' is not enabled in the source site.', ['source_provider' => $this->pluginDefinition['source_provider']]);
|
||||
throw new RequirementsException('The module ' . $this->pluginDefinition['source_module'] . ' is not enabled in the source site.', ['source_module' => $this->pluginDefinition['source_module']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ 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.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal i18n_variable source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "variable_translation"
|
||||
* )
|
||||
*/
|
||||
class VariableTranslation extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The variable names to fetch.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $variables;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->variables = $this->configuration['variables'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
return new \ArrayIterator($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.
|
||||
* A key/value pair is added for the language code. Only those values are
|
||||
* returned that are actually in the database.
|
||||
*/
|
||||
protected function values() {
|
||||
$values = [];
|
||||
$result = $this->prepareQuery()->execute()->FetchAllAssoc('language');
|
||||
foreach ($result as $i18n_variable) {
|
||||
$values[]['language'] = $i18n_variable->language;
|
||||
}
|
||||
$result = $this->prepareQuery()->execute()->FetchAll();
|
||||
foreach ($result as $i18n_variable) {
|
||||
foreach ($values as $key => $value) {
|
||||
if ($values[$key]['language'] === $i18n_variable->language) {
|
||||
$values[$key][$i18n_variable->name] = unserialize($i18n_variable->value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return $this->initializeIterator()->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array_combine($this->variables, $this->variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->getDatabase()
|
||||
->select('i18n_variable', 'v')
|
||||
->fields('v')
|
||||
->condition('name', (array) $this->configuration['variables'], 'IN');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['language']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,10 +2,7 @@
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\State\StateInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
@trigger_error('The ' . __NAMESPACE__ . '\i18nVariable is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use ' . __NAMESPACE__ . '\VariableTranslation', E_USER_DEPRECATED);
|
||||
|
||||
/**
|
||||
* Drupal i18n_variable source from database.
|
||||
@@ -13,88 +10,10 @@ use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
* @MigrateSource(
|
||||
* id = "i18n_variable"
|
||||
* )
|
||||
*
|
||||
* @deprecated in Drupal 8.4.x and will be removed in Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation instead.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2898649
|
||||
*/
|
||||
class i18nVariable extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The variable names to fetch.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $variables;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityManagerInterface $entity_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_manager);
|
||||
$this->variables = $this->configuration['variables'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
return new \ArrayIterator($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.
|
||||
* A key/value pair is added for the language code. Only those values are
|
||||
* returned that are actually in the database.
|
||||
*/
|
||||
protected function values() {
|
||||
$values = [];
|
||||
$result = $this->prepareQuery()->execute()->FetchAllAssoc('language');
|
||||
foreach ($result as $i18n_variable) {
|
||||
$values[]['language'] = $i18n_variable->language;
|
||||
}
|
||||
$result = $this->prepareQuery()->execute()->FetchAll();
|
||||
foreach ($result as $i18n_variable) {
|
||||
foreach ($values as $key => $value) {
|
||||
if ($values[$key]['language'] === $i18n_variable->language) {
|
||||
$values[$key][$i18n_variable->name] = unserialize($i18n_variable->value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count() {
|
||||
return $this->initializeIterator()->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array_combine($this->variables, $this->variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->getDatabase()
|
||||
->select('i18n_variable', 'v')
|
||||
->fields('v')
|
||||
->condition('name', (array) $this->configuration['variables'], 'IN');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['language']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
class i18nVariable extends VariableTranslation {}
|
||||
|
||||
+189
-2
@@ -1942,6 +1942,54 @@ $connection->insert('comments')
|
||||
'mail' => 'comment3@example.com',
|
||||
'homepage' => 'https://www.drupal.org',
|
||||
))
|
||||
->values(array(
|
||||
'cid' => '4',
|
||||
'pid' => '0',
|
||||
'nid' => '19',
|
||||
'uid' => '1',
|
||||
'subject' => 'Subject 1',
|
||||
'comment' => 'Comment 1',
|
||||
'hostname' => '127.0.0.1',
|
||||
'timestamp' => '1501955780',
|
||||
'status' => '0',
|
||||
'format' => '1',
|
||||
'thread' => '01/',
|
||||
'name' => 'root',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
))
|
||||
->values(array(
|
||||
'cid' => '5',
|
||||
'pid' => '4',
|
||||
'nid' => '19',
|
||||
'uid' => '1',
|
||||
'subject' => 'Subject 2',
|
||||
'comment' => 'Comment 2',
|
||||
'hostname' => '127.0.0.1',
|
||||
'timestamp' => '1501955792',
|
||||
'status' => '0',
|
||||
'format' => '1',
|
||||
'thread' => '01.00/',
|
||||
'name' => 'root',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
))
|
||||
->values(array(
|
||||
'cid' => '6',
|
||||
'pid' => '5',
|
||||
'nid' => '19',
|
||||
'uid' => '1',
|
||||
'subject' => 'Subject 3',
|
||||
'comment' => 'Comment 3',
|
||||
'hostname' => '127.0.0.1',
|
||||
'timestamp' => '1501955803',
|
||||
'status' => '0',
|
||||
'format' => '1',
|
||||
'thread' => '01.00.00/',
|
||||
'name' => 'root',
|
||||
'mail' => '',
|
||||
'homepage' => '',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('config', array(
|
||||
@@ -8345,6 +8393,19 @@ $connection->schema()->createTable('forum', array(
|
||||
'mysql_character_set' => 'utf8',
|
||||
));
|
||||
|
||||
$connection->insert('forum')
|
||||
->fields(array(
|
||||
'nid',
|
||||
'vid',
|
||||
'tid',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '19',
|
||||
'vid' => '22',
|
||||
'tid' => '8',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('history', array(
|
||||
'fields' => array(
|
||||
'uid' => array(
|
||||
@@ -8424,6 +8485,11 @@ $connection->insert('history')
|
||||
'nid' => '18',
|
||||
'timestamp' => '1493066711',
|
||||
))
|
||||
->values(array(
|
||||
'uid' => '1',
|
||||
'nid' => '19',
|
||||
'timestamp' => '1501955803',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('i18n_blocks', array(
|
||||
@@ -9558,6 +9624,22 @@ $connection->insert('i18n_strings')
|
||||
'objectindex' => '0',
|
||||
'format' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1672',
|
||||
'objectid' => '6',
|
||||
'type' => 'vocabulary',
|
||||
'property' => 'name',
|
||||
'objectindex' => '6',
|
||||
'format' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1673',
|
||||
'objectid' => '7',
|
||||
'type' => 'vocabulary',
|
||||
'property' => 'name',
|
||||
'objectindex' => '7',
|
||||
'format' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('i18n_variable', array(
|
||||
@@ -22010,6 +22092,20 @@ $connection->insert('locales_source')
|
||||
'source' => '%name: Title mismatch. Please check your selection.',
|
||||
'version' => 'none',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1672',
|
||||
'location' => 'vocabulary:6:name',
|
||||
'textgroup' => 'taxonomy',
|
||||
'source' => 'Type',
|
||||
'version' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'lid' => '1673',
|
||||
'location' => 'vocabulary:7:name',
|
||||
'textgroup' => 'taxonomy',
|
||||
'source' => 'Forums',
|
||||
'version' => '1',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('locales_target', array(
|
||||
@@ -43170,6 +43266,23 @@ $connection->insert('node')
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '19',
|
||||
'vid' => '22',
|
||||
'type' => 'forum',
|
||||
'language' => '',
|
||||
'title' => 'New Forum Topic',
|
||||
'uid' => '1',
|
||||
'status' => '1',
|
||||
'created' => '1501955771',
|
||||
'changed' => '1501955771',
|
||||
'comment' => '2',
|
||||
'promote' => '0',
|
||||
'moderate' => '0',
|
||||
'sticky' => '0',
|
||||
'tnid' => '0',
|
||||
'translate' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_access', array(
|
||||
@@ -43369,6 +43482,13 @@ $connection->insert('node_comment_statistics')
|
||||
'last_comment_uid' => '1',
|
||||
'comment_count' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '19',
|
||||
'last_comment_timestamp' => '1501955803',
|
||||
'last_comment_name' => '',
|
||||
'last_comment_uid' => '1',
|
||||
'comment_count' => '3',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_counter', array(
|
||||
@@ -43444,6 +43564,12 @@ $connection->insert('node_counter')
|
||||
'daycount' => '1',
|
||||
'timestamp' => '1493066711',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '19',
|
||||
'totalcount' => '4',
|
||||
'daycount' => '4',
|
||||
'timestamp' => '1501955803',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_revisions', array(
|
||||
@@ -43750,6 +43876,17 @@ $connection->insert('node_revisions')
|
||||
'timestamp' => '1494966544',
|
||||
'format' => '1',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '19',
|
||||
'vid' => '22',
|
||||
'uid' => '1',
|
||||
'title' => 'New Forum Topic',
|
||||
'body' => 'New Forum Body',
|
||||
'teaser' => 'New Forum Body',
|
||||
'log' => '',
|
||||
'timestamp' => '1501955771',
|
||||
'format' => '1',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('node_type', array(
|
||||
@@ -46026,6 +46163,15 @@ $connection->insert('term_data')
|
||||
'language' => 'fr',
|
||||
'trid' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'tid' => '8',
|
||||
'vid' => '7',
|
||||
'name' => 'General discussion',
|
||||
'description' => '',
|
||||
'weight' => '0',
|
||||
'language' => '',
|
||||
'trid' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('term_hierarchy', array(
|
||||
@@ -46073,6 +46219,10 @@ $connection->insert('term_hierarchy')
|
||||
'tid' => '7',
|
||||
'parent' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'tid' => '8',
|
||||
'parent' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'tid' => '3',
|
||||
'parent' => '2',
|
||||
@@ -46158,6 +46308,11 @@ $connection->insert('term_node')
|
||||
'vid' => '2',
|
||||
'tid' => '5',
|
||||
))
|
||||
->values(array(
|
||||
'nid' => '19',
|
||||
'vid' => '22',
|
||||
'tid' => '8',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('term_relation', array(
|
||||
@@ -47636,7 +47791,7 @@ $connection->insert('variable')
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'forum_nav_vocabulary',
|
||||
'value' => 's:1:"1";',
|
||||
'value' => 's:1:"7";',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'forum_order',
|
||||
@@ -48226,6 +48381,34 @@ $connection->insert('vocabulary')
|
||||
'weight' => '7',
|
||||
'language' => '',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '6',
|
||||
'name' => 'Type',
|
||||
'description' => '',
|
||||
'help' => '',
|
||||
'relations' => '1',
|
||||
'hierarchy' => '0',
|
||||
'multiple' => '0',
|
||||
'required' => '0',
|
||||
'tags' => '0',
|
||||
'module' => 'taxonomy',
|
||||
'weight' => '0',
|
||||
'language' => '',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '7',
|
||||
'name' => 'Forums',
|
||||
'description' => '',
|
||||
'help' => '',
|
||||
'relations' => '1',
|
||||
'hierarchy' => '0',
|
||||
'multiple' => '0',
|
||||
'required' => '0',
|
||||
'tags' => '0',
|
||||
'module' => 'taxonomy',
|
||||
'weight' => '0',
|
||||
'language' => '',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('vocabulary_node_types', array(
|
||||
@@ -48261,13 +48444,17 @@ $connection->insert('vocabulary_node_types')
|
||||
'type' => 'article',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '1',
|
||||
'vid' => '7',
|
||||
'type' => 'forum',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '4',
|
||||
'type' => 'page',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '6',
|
||||
'type' => 'sponsor',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '1',
|
||||
'type' => 'story',
|
||||
|
||||
+2163
-33
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Module for Migrate CCK Field Plugin Manager testing.
|
||||
*/
|
||||
|
||||
use Drupal\migrate_cckfield_plugin_manager_test\Plugin\migrate\cckfield\D6FileField;
|
||||
|
||||
function migrate_cckfield_plugin_manager_test_migrate_field_info_alter(array &$definitions) {
|
||||
if (isset($definitions['filefield'])) {
|
||||
$definitions['filefield']['class'] = D6FileField::class;
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -19,11 +19,10 @@ class D6FileField extends CckFieldPluginBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {}
|
||||
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
$migration->setProcessOfProperty($field_name, [
|
||||
'class' => static::class,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-5
@@ -12,11 +12,6 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
*/
|
||||
class D6NoCoreVersionSpecified extends CckFieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
+1
-16
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\migrate_field_plugin_manager_test\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
@@ -14,18 +13,4 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class D6FileField extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {}
|
||||
|
||||
}
|
||||
class D6FileField extends FieldPluginBase {}
|
||||
|
||||
-12
@@ -3,7 +3,6 @@
|
||||
namespace Drupal\migrate_field_plugin_manager_test\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
@@ -12,16 +11,5 @@ use Drupal\migrate\Plugin\MigrationInterface;
|
||||
*/
|
||||
class D6NoCoreVersionSpecified extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {}
|
||||
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-08-16
|
||||
version: '8.3.7'
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1502903957
|
||||
datestamp: 1509719929
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel;
|
||||
|
||||
use Drupal\migrate_field_plugin_manager_test\Plugin\migrate\cckfield\d6\FileField;
|
||||
use Drupal\migrate_cckfield_plugin_manager_test\Plugin\migrate\cckfield\D6FileField;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ class CckFieldBackwardsCompatibilityTest extends MigrateDrupal6TestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['file', 'migrate_field_plugin_manager_test'];
|
||||
public static $modules = ['file', 'migrate_cckfield_plugin_manager_test'];
|
||||
|
||||
/**
|
||||
* Ensures that the cckfield backwards compatibility layer is invoked.
|
||||
@@ -23,7 +23,7 @@ class CckFieldBackwardsCompatibilityTest extends MigrateDrupal6TestBase {
|
||||
->get('plugin.manager.migration')
|
||||
->getDefinition('d6_node:story');
|
||||
|
||||
$this->assertSame(FileField::class, $migration['process']['field_test_filefield']['class']);
|
||||
$this->assertSame(D6FileField::class, $migration['process']['field_test_filefield']['class']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,28 +22,20 @@ class MigrateCckFieldPluginManagerTest extends MigrateDrupalTestBase {
|
||||
public function testPluginSelection() {
|
||||
$plugin_manager = \Drupal::service('plugin.manager.migrate.cckfield');
|
||||
|
||||
$plugin_id = $plugin_manager->getPluginIdFromFieldType('filefield', ['core' => 6]);
|
||||
$this->assertIdentical('Drupal\\file\\Plugin\\migrate\\cckfield\\d6\\FileField', get_class($plugin_manager->createInstance($plugin_id, ['core' => 6])));
|
||||
$this->assertSame('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
|
||||
|
||||
try {
|
||||
// If this test passes, getPluginIdFromFieldType will raise a
|
||||
// PluginNotFoundException and we'll never reach fail().
|
||||
$plugin_manager->getPluginIdFromFieldType('filefield', ['core' => 7]);
|
||||
$plugin_manager->getPluginIdFromFieldType('d6_file', ['core' => 7]);
|
||||
$this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
$this->assertIdentical($e->getMessage(), "Plugin ID 'filefield' was not found.");
|
||||
$this->assertSame($e->getMessage(), "Plugin ID 'd6_file' was not found.");
|
||||
}
|
||||
|
||||
$this->assertIdentical('image', $plugin_manager->getPluginIdFromFieldType('image', ['core' => 7]));
|
||||
$this->assertIdentical('file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 7]));
|
||||
$this->assertIdentical('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
|
||||
|
||||
$this->assertIdentical('text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 6]));
|
||||
$this->assertIdentical('text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 7]));
|
||||
|
||||
// Test fallback when no core version is specified.
|
||||
$this->assertIdentical('d6_no_core_version_specified', $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 6]));
|
||||
$this->assertSame('d6_no_core_version_specified', $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 6]));
|
||||
|
||||
try {
|
||||
// If this test passes, getPluginIdFromFieldType will raise a
|
||||
@@ -52,7 +44,7 @@ class MigrateCckFieldPluginManagerTest extends MigrateDrupalTestBase {
|
||||
$this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
$this->assertIdentical($e->getMessage(), "Plugin ID 'd6_no_core_version_specified' was not found.");
|
||||
$this->assertSame($e->getMessage(), "Plugin ID 'd6_no_core_version_specified' was not found.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class MigrateFieldPluginManagerTest extends MigrateDrupalTestBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_field_plugin_manager_test'];
|
||||
public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'link', 'migrate_field_plugin_manager_test'];
|
||||
|
||||
/**
|
||||
* Tests that the correct MigrateField plugins are used.
|
||||
@@ -32,7 +32,13 @@ class MigrateFieldPluginManagerTest extends MigrateDrupalTestBase {
|
||||
$this->assertIdentical($e->getMessage(), "Plugin ID 'filefield' was not found.");
|
||||
}
|
||||
|
||||
$this->assertIdentical('link', $plugin_manager->getPluginIdFromFieldType('link', ['core' => 6]));
|
||||
$this->assertIdentical('link_field', $plugin_manager->getPluginIdFromFieldType('link_field', ['core' => 7]));
|
||||
$this->assertIdentical('image', $plugin_manager->getPluginIdFromFieldType('image', ['core' => 7]));
|
||||
$this->assertIdentical('file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 7]));
|
||||
$this->assertIdentical('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
|
||||
$this->assertIdentical('d6_text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 6]));
|
||||
$this->assertIdentical('d7_text', $plugin_manager->getPluginIdFromFieldType('text', ['core' => 7]));
|
||||
|
||||
// Test fallback when no core version is specified.
|
||||
$this->assertIdentical('d6_no_core_version_specified', $plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 6]));
|
||||
|
||||
@@ -114,7 +114,7 @@ class EntityContentBaseTest extends MigrateDrupal6TestBase {
|
||||
$message = $this->prophesize(MigrateMessageInterface::class);
|
||||
// Match the expected message. Can't use default argument types, because
|
||||
// we need to convert to string from TranslatableMarkup.
|
||||
$argument = Argument::that(function($msg) {
|
||||
$argument = Argument::that(function ($msg) {
|
||||
return strpos((string) $msg, "This entity type does not support translation") !== FALSE;
|
||||
});
|
||||
$message->display($argument, Argument::any())
|
||||
|
||||
@@ -43,7 +43,7 @@ class DrupalSqlBaseTest extends MigrateTestCase {
|
||||
*/
|
||||
public function testSourceProviderNotActive() {
|
||||
$plugin_definition['requirements_met'] = TRUE;
|
||||
$plugin_definition['source_provider'] = 'module1';
|
||||
$plugin_definition['source_module'] = 'module1';
|
||||
/** @var \Drupal\Core\State\StateInterface $state */
|
||||
$state = $this->getMock('Drupal\Core\State\StateInterface');
|
||||
/** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
|
||||
@@ -57,7 +57,7 @@ class DrupalSqlBaseTest extends MigrateTestCase {
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
// Ensure requirements are set on the exception.
|
||||
$this->assertEquals(['source_provider' => 'module1'], $e->getRequirements());
|
||||
$this->assertEquals(['source_module' => 'module1'], $e->getRequirements());
|
||||
// Re-throw so PHPUnit can assert the exception.
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -150,10 +150,10 @@ class TestDrupal6SqlBase extends DrupalSqlBase {
|
||||
'owner' => t("A theme's 'parent'. Can be either a theme or an engine."),
|
||||
'status' => t('Boolean indicating whether or not this item is enabled.'),
|
||||
'throttle' => t('Boolean indicating whether this item is disabled when the throttle.module disables throttleable items.'),
|
||||
'bootstrap' => t('Boolean indicating whether this module is loaded during Drupal\'s early bootstrapping phase (e.g. even before the page cache is consulted).'),
|
||||
'schema_version' => t('The module\'s database schema version number.'),
|
||||
'weight' => t('The order in which this module\'s hooks should be invoked.'),
|
||||
'info' => t('A serialized array containing information from the module\'s .info file.'),
|
||||
'bootstrap' => t("Boolean indicating whether this module is loaded during Drupal's early bootstrapping phase (e.g. even before the page cache is consulted)."),
|
||||
'schema_version' => t("The module's database schema version number."),
|
||||
'weight' => t("The order in which this module's hooks should be invoked."),
|
||||
'info' => t("A serialized array containing information from the module's .info file."),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests the variable source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableTranslationTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\migrate_drupal\Plugin\migrate\source\d6\VariableTranslation';
|
||||
|
||||
/**
|
||||
* Define bare minimum migration configuration.
|
||||
*/
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'highWaterProperty' => ['field' => 'test'],
|
||||
'source' => [
|
||||
'plugin' => 'variable_translation',
|
||||
'variables' => [
|
||||
'site_slogan',
|
||||
'site_name',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Expected results from the source.
|
||||
*/
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'language' => 'fr',
|
||||
'site_slogan' => 'Migrate est génial',
|
||||
'site_name' => 'nom de site',
|
||||
],
|
||||
[
|
||||
'language' => 'mi',
|
||||
'site_slogan' => 'Ko whakamataku heke',
|
||||
'site_name' => 'ingoa_pae',
|
||||
]
|
||||
];
|
||||
|
||||
/**
|
||||
* Database contents for tests.
|
||||
*/
|
||||
protected $databaseContents = [
|
||||
'i18n_variable' => [
|
||||
['name' => 'site_slogan', 'language' => 'fr', 'value' => 's:19:"Migrate est génial";'],
|
||||
['name' => 'site_name', 'language' => 'fr', 'value' => 's:11:"nom de site";'],
|
||||
['name' => 'site_slogan', 'language' => 'mi', 'value' => 's:19:"Ko whakamataku heke";'],
|
||||
['name' => 'site_name', 'language' => 'mi', 'value' => 's:9:"ingoa_pae";'],
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
* Tests the variable source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
* @group legacy
|
||||
*/
|
||||
class i18nVariableTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user