Core and composer updates
This commit is contained in:
parent
a82634bb98
commit
62cac30480
1118 changed files with 21770 additions and 6306 deletions
|
@ -1,4 +1,12 @@
|
|||
services:
|
||||
plugin.manager.migrate.field:
|
||||
class: Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager
|
||||
arguments:
|
||||
- field
|
||||
- '@container.namespaces'
|
||||
- '@cache.discovery'
|
||||
- '@module_handler'
|
||||
- '\Drupal\migrate_drupal\Annotation\MigrateField'
|
||||
plugin.manager.migrate.cckfield:
|
||||
class: Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManager
|
||||
arguments:
|
||||
|
@ -7,3 +15,4 @@ services:
|
|||
- '@cache.discovery'
|
||||
- '@module_handler'
|
||||
- '\Drupal\migrate_drupal\Annotation\MigrateCckField'
|
||||
deprecated: The "%service_id%" service is deprecated. You should use the 'plugin.manager.migrate.field' service instead. See https://www.drupal.org/node/2751897
|
||||
|
|
|
@ -2,53 +2,20 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
@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);
|
||||
|
||||
/**
|
||||
* Defines a cckfield plugin annotation object.
|
||||
* Deprecated: Defines a cckfield plugin annotation object.
|
||||
*
|
||||
* cckfield plugins are variously responsible for handling the migration of
|
||||
* CCK fields from Drupal 6 to Drupal 8, and Field API fields from Drupal 7
|
||||
* to Drupal 8. They are allowed to alter CCK-related migrations when migrations
|
||||
* are being generated, and can compute destination field types for individual
|
||||
* fields during the actual migration process.
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Annotation\MigrateField instead.
|
||||
*
|
||||
* Plugin Namespace: Plugin\migrate\cckfield
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class MigrateCckField extends Plugin {
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __construct($values) {
|
||||
parent::__construct($values);
|
||||
// Provide default value for core property, in case it's missing.
|
||||
if (empty($this->definition['core'])) {
|
||||
$this->definition['core'] = [6];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The plugin ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Map of D6 and D7 field types to D8 field type plugin IDs.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $type_map = [];
|
||||
|
||||
/**
|
||||
* The Drupal core version(s) this plugin applies to.
|
||||
*
|
||||
* @var int[]
|
||||
*/
|
||||
public $core = [];
|
||||
class MigrateCckField extends MigrateField {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
||||
/**
|
||||
* Defines a field plugin annotation object.
|
||||
*
|
||||
* Field plugins are responsible for handling the migration of custom fields
|
||||
* (provided by CCK in Drupal 6 and Field API in Drupal 7) to Drupal 8. They are
|
||||
* allowed to alter fieldable entity migrations when these migrations are being
|
||||
* generated, and can compute destination field types for individual fields
|
||||
* during the actual migration process.
|
||||
*
|
||||
* Plugin Namespace: Plugin\migrate\field
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class MigrateField extends Plugin {
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function __construct($values) {
|
||||
parent::__construct($values);
|
||||
// Provide default value for core property, in case it's missing.
|
||||
if (empty($this->definition['core'])) {
|
||||
$this->definition['core'] = [6];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The plugin ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Map of D6 and D7 field types to D8 field type plugin IDs.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
public $type_map = [];
|
||||
|
||||
/**
|
||||
* The Drupal core version(s) this plugin applies to.
|
||||
*
|
||||
* @var int[]
|
||||
*/
|
||||
public $core = [];
|
||||
|
||||
}
|
|
@ -2,64 +2,19 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
@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;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Provides an interface for all CCK field type plugins.
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Annotation\MigrateField instead.
|
||||
*/
|
||||
interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processField(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field instance migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field widget migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldWidget(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field formatter migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\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();
|
||||
interface MigrateCckFieldInterface extends MigrateFieldInterface {
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the cck bundle migrations.
|
||||
|
@ -73,15 +28,4 @@ interface MigrateCckFieldInterface extends PluginInspectionInterface {
|
|||
*/
|
||||
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data);
|
||||
|
||||
/**
|
||||
* Computes the destination type of a migrated field.
|
||||
*
|
||||
* @param \Drupal\migrate\Row $row
|
||||
* The field being migrated.
|
||||
*
|
||||
* @return string
|
||||
* The destination field type.
|
||||
*/
|
||||
public function getFieldType(Row $row);
|
||||
|
||||
}
|
||||
|
|
|
@ -2,54 +2,16 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
@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);
|
||||
|
||||
/**
|
||||
* Plugin manager for migrate cckfield plugins.
|
||||
* Deprecated: Plugin manager for migrate field plugins.
|
||||
*
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
|
||||
* @see \Drupal\migrate\Annotation\MigrateCckField
|
||||
* @see plugin_api
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManager instead.
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
class MigrateCckFieldPluginManager extends MigratePluginManager implements MigrateCckFieldPluginManagerInterface {
|
||||
|
||||
/**
|
||||
* The default version of core to use for cck field plugins.
|
||||
*
|
||||
* These plugins were initially only built and used for Drupal 6 fields.
|
||||
* Having been extended for Drupal 7 with a "core" annotation, we fall back to
|
||||
* Drupal 6 where none exists.
|
||||
*/
|
||||
const DEFAULT_CORE_VERSION = 6;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL) {
|
||||
$core = static::DEFAULT_CORE_VERSION;
|
||||
if (!empty($configuration['core'])) {
|
||||
$core = $configuration['core'];
|
||||
}
|
||||
elseif (!empty($migration->getPluginDefinition()['migration_tags'])) {
|
||||
foreach ($migration->getPluginDefinition()['migration_tags'] as $tag) {
|
||||
if ($tag == 'Drupal 7') {
|
||||
$core = 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getDefinitions() as $plugin_id => $definition) {
|
||||
if (in_array($core, $definition['core'])) {
|
||||
if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) {
|
||||
return $plugin_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new PluginNotFoundException($field_type);
|
||||
}
|
||||
|
||||
}
|
||||
class MigrateCckFieldPluginManager extends MigrateFieldPluginManager implements MigrateCckFieldPluginManagerInterface { }
|
||||
|
|
|
@ -2,27 +2,14 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
@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);
|
||||
|
||||
interface MigrateCckFieldPluginManagerInterface extends MigratePluginManagerInterface {
|
||||
|
||||
/**
|
||||
* Get the plugin ID from the field type.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type being migrated.
|
||||
* @param array $configuration
|
||||
* (optional) An array of configuration relevant to the plugin instance.
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface|null $migration
|
||||
* (optional) The current migration instance.
|
||||
*
|
||||
* @return string
|
||||
* The ID of the plugin for the field_type if available.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
|
||||
* If the plugin cannot be determined, such as if the field type is invalid.
|
||||
*/
|
||||
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL);
|
||||
|
||||
}
|
||||
/**
|
||||
* Provides an interface for cck field plugin manager.
|
||||
*
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManagerInterface instead.
|
||||
*/
|
||||
interface MigrateCckFieldPluginManagerInterface extends MigrateFieldPluginManagerInterface { }
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* Provides an interface for all field type plugins.
|
||||
*/
|
||||
interface MigrateFieldInterface extends PluginInspectionInterface {
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processField(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field instance migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field widget migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
||||
* The migration entity.
|
||||
*/
|
||||
public function processFieldWidget(MigrationInterface $migration);
|
||||
|
||||
/**
|
||||
* Apply any custom processing to the field formatter migration.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\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 field bundle migrations.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\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 FieldValues::fieldData().
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data);
|
||||
|
||||
/**
|
||||
* Computes the destination type of a migrated field.
|
||||
*
|
||||
* @param \Drupal\migrate\Row $row
|
||||
* The field being migrated.
|
||||
*
|
||||
* @return string
|
||||
* The destination field type.
|
||||
*/
|
||||
public function getFieldType(Row $row);
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* Plugin manager for migrate cckfield plugins.
|
||||
*
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
|
||||
* @see \Drupal\migrate\Annotation\MigrateField
|
||||
* @see plugin_api
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
class MigrateFieldPluginManager extends MigratePluginManager implements MigrateFieldPluginManagerInterface {
|
||||
|
||||
/**
|
||||
* The default version of core to use for field plugins.
|
||||
*
|
||||
* These plugins were initially only built and used for Drupal 6 fields.
|
||||
* Having been extended for Drupal 7 with a "core" annotation, we fall back to
|
||||
* Drupal 6 where none exists.
|
||||
*/
|
||||
const DEFAULT_CORE_VERSION = 6;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL) {
|
||||
$core = static::DEFAULT_CORE_VERSION;
|
||||
if (!empty($configuration['core'])) {
|
||||
$core = $configuration['core'];
|
||||
}
|
||||
elseif (!empty($migration->getPluginDefinition()['migration_tags'])) {
|
||||
foreach ($migration->getPluginDefinition()['migration_tags'] as $tag) {
|
||||
if ($tag == 'Drupal 7') {
|
||||
$core = 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$definitions = $this->getDefinitions();
|
||||
foreach ($definitions as $plugin_id => $definition) {
|
||||
if (in_array($core, $definition['core'])) {
|
||||
if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) {
|
||||
return $plugin_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new PluginNotFoundException($field_type);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin;
|
||||
|
||||
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
interface MigrateFieldPluginManagerInterface extends MigratePluginManagerInterface {
|
||||
|
||||
/**
|
||||
* Get the plugin ID from the field type.
|
||||
*
|
||||
* @param string $field_type
|
||||
* The field type being migrated.
|
||||
* @param array $configuration
|
||||
* (optional) An array of configuration relevant to the plugin instance.
|
||||
* @param \Drupal\migrate\Plugin\MigrationInterface|null $migration
|
||||
* (optional) The current migration instance.
|
||||
*
|
||||
* @return string
|
||||
* The ID of the plugin for the field_type if available.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
|
||||
* If the plugin cannot be determined, such as if the field type is invalid.
|
||||
*/
|
||||
public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL);
|
||||
|
||||
}
|
|
@ -2,131 +2,21 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
|
||||
use Drupal\migrate\Plugin\MigratePluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
@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.
|
||||
*/
|
||||
class CckMigration extends Migration implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* Flag indicating whether the CCK data has been filled already.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $init = FALSE;
|
||||
|
||||
/**
|
||||
* List of cckfield plugin IDs which have already run.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $processedFieldTypes = [];
|
||||
|
||||
/**
|
||||
* Already-instantiated cckfield plugins, keyed by ID.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
|
||||
*/
|
||||
protected $cckPluginCache;
|
||||
|
||||
/**
|
||||
* The cckfield plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Constructs a CckMigration.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface $cck_manager
|
||||
* The cckfield plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
|
||||
* The migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManagerInterface $source_plugin_manager
|
||||
* The source migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManagerInterface $process_plugin_manager
|
||||
* The process migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
|
||||
* The destination migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManagerInterface $idmap_plugin_manager
|
||||
* The ID map migration plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateCckFieldPluginManagerInterface $cck_manager, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManagerInterface $source_plugin_manager, MigratePluginManagerInterface $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManagerInterface $idmap_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration_plugin_manager, $source_plugin_manager, $process_plugin_manager, $destination_plugin_manager, $idmap_plugin_manager);
|
||||
$this->cckPluginManager = $cck_manager;
|
||||
}
|
||||
class CckMigration extends FieldMigration {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('plugin.manager.migrate.cckfield'),
|
||||
$container->get('plugin.manager.migration'),
|
||||
$container->get('plugin.manager.migrate.source'),
|
||||
$container->get('plugin.manager.migrate.process'),
|
||||
$container->get('plugin.manager.migrate.destination'),
|
||||
$container->get('plugin.manager.migrate.id_map')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProcess() {
|
||||
if (!$this->init) {
|
||||
$this->init = TRUE;
|
||||
$source_plugin = $this->migrationPluginManager->createInstance($this->pluginId)->getSourcePlugin();
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
try {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
// Kill the rest of the method.
|
||||
$source_plugin = [];
|
||||
}
|
||||
}
|
||||
foreach ($source_plugin as $row) {
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
try {
|
||||
$plugin_id = $this->cckPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
}
|
||||
catch (PluginNotFoundException $ex) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($this->processedFieldTypes[$field_type])) {
|
||||
$this->processedFieldTypes[$field_type] = TRUE;
|
||||
// Allow the cckfield plugin to alter the migration as necessary so
|
||||
// that it knows how to handle fields of this type.
|
||||
if (!isset($this->cckPluginCache[$field_type])) {
|
||||
$this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($plugin_id, [], $this);
|
||||
}
|
||||
call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::getProcess();
|
||||
}
|
||||
const PLUGIN_METHOD = 'cck_plugin_method';
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
use Drupal\migrate\Exception\RequirementsException;
|
||||
use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
|
||||
use Drupal\migrate\Plugin\MigratePluginManager;
|
||||
use Drupal\migrate\Plugin\Migration;
|
||||
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
|
||||
use Drupal\migrate\Plugin\RequirementsInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateFieldPluginManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Migration plugin class for migrations dealing with field config and values.
|
||||
*/
|
||||
class FieldMigration extends Migration implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* Defines which configuration option has the migration processing function.
|
||||
*
|
||||
* Default method is 'field_plugin_method'. For backwards compatibility,
|
||||
* this constant is overridden in the CckMigration class, in order to
|
||||
* fallback to the old 'cck_plugin_method'.
|
||||
*
|
||||
* @const string
|
||||
*/
|
||||
const PLUGIN_METHOD = 'field_plugin_method';
|
||||
|
||||
/**
|
||||
* Flag indicating whether the field data has been filled already.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $init = FALSE;
|
||||
|
||||
/**
|
||||
* List of field plugin IDs which have already run.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $processedFieldTypes = [];
|
||||
|
||||
/**
|
||||
* Already-instantiated field plugins, keyed by ID.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface[]
|
||||
*/
|
||||
protected $fieldPluginCache;
|
||||
|
||||
/**
|
||||
* The field plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManagerInterface
|
||||
*/
|
||||
protected $fieldPluginManager;
|
||||
|
||||
/**
|
||||
* Already-instantiated cckfield plugins, keyed by ID.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface[]
|
||||
*/
|
||||
protected $cckPluginCache;
|
||||
|
||||
/**
|
||||
* The cckfield plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface
|
||||
*/
|
||||
protected $cckPluginManager;
|
||||
|
||||
/**
|
||||
* Constructs a FieldMigration.
|
||||
*
|
||||
* @param array $configuration
|
||||
* Plugin configuration.
|
||||
* @param string $plugin_id
|
||||
* The plugin ID.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin definition.
|
||||
* @param \Drupal\migrate_drupal\Plugin\MigrateCckFieldPluginManagerInterface $cck_manager
|
||||
* The cckfield plugin manager.
|
||||
* @param \Drupal\migrate_drupal\Plugin\MigrateFieldPluginManagerInterface $field_manager
|
||||
* The field plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
|
||||
* The migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
|
||||
* The source migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
|
||||
* The process migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
|
||||
* The destination migration plugin manager.
|
||||
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
|
||||
* The ID map migration plugin manager.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateCckFieldPluginManagerInterface $cck_manager, MigrateFieldPluginManagerInterface $field_manager, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $source_plugin_manager, MigratePluginManager $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManager $idmap_plugin_manager) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration_plugin_manager, $source_plugin_manager, $process_plugin_manager, $destination_plugin_manager, $idmap_plugin_manager);
|
||||
$this->cckPluginManager = $cck_manager;
|
||||
$this->fieldPluginManager = $field_manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('plugin.manager.migrate.cckfield'),
|
||||
$container->get('plugin.manager.migrate.field'),
|
||||
$container->get('plugin.manager.migration'),
|
||||
$container->get('plugin.manager.migrate.source'),
|
||||
$container->get('plugin.manager.migrate.process'),
|
||||
$container->get('plugin.manager.migrate.destination'),
|
||||
$container->get('plugin.manager.migrate.id_map')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getProcess() {
|
||||
if (!$this->init) {
|
||||
$this->init = TRUE;
|
||||
$source_plugin = $this->migrationPluginManager->createInstance($this->pluginId)->getSourcePlugin();
|
||||
if ($source_plugin instanceof RequirementsInterface) {
|
||||
try {
|
||||
$source_plugin->checkRequirements();
|
||||
}
|
||||
catch (RequirementsException $e) {
|
||||
// Kill the rest of the method.
|
||||
$source_plugin = [];
|
||||
}
|
||||
}
|
||||
foreach ($source_plugin as $row) {
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
|
||||
try {
|
||||
$plugin_id = $this->cckPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
$Manager = $this->cckPluginManager;
|
||||
}
|
||||
catch (PluginNotFoundException $ex) {
|
||||
try {
|
||||
$plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type, [], $this);
|
||||
$Manager = $this->fieldPluginManager;
|
||||
}
|
||||
catch (PluginNotFoundException $ex) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
$method = $this->pluginDefinition[static::PLUGIN_METHOD];
|
||||
call_user_func([$this->fieldPluginCache[$field_type], $method], $this);
|
||||
}
|
||||
}
|
||||
return parent::getProcess();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,82 +2,49 @@
|
|||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\cckfield;
|
||||
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
@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\Row;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* The base class for all cck field plugins.
|
||||
* The base class for all field plugins.
|
||||
*
|
||||
* @see \Drupal\migrate\Plugin\MigratePluginManager
|
||||
* @see \Drupal\migrate_drupal\Annotation\MigrateCckField
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface
|
||||
* @see plugin_api
|
||||
* @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use
|
||||
* \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead.
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
abstract class CckFieldPluginBase extends PluginBase implements MigrateCckFieldInterface {
|
||||
abstract class CckFieldPluginBase extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Apply any custom processing to the field bundle migrations.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\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 FieldValues::fieldData().
|
||||
*/
|
||||
public function processField(MigrationInterface $migration) {
|
||||
$process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId;
|
||||
$migration->mergeProcessOfProperty('type', $process);
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
// Provide a bridge to the old method declared on the interface and now an
|
||||
// abstract method in this class.
|
||||
return $this->processCckFieldValues($migration, $field_name, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Apply any custom processing to the field bundle migrations.
|
||||
*
|
||||
* @param \Drupal\migrate\Plugin\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 FieldValues::fieldData().
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldType(Row $row) {
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
|
||||
if (isset($this->pluginDefinition['type_map'][$field_type])) {
|
||||
return $this->pluginDefinition['type_map'][$field_type];
|
||||
}
|
||||
else {
|
||||
return $field_type;
|
||||
}
|
||||
}
|
||||
abstract public function processCckFieldValues(MigrationInterface $migration, $field_name, $data);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\field;
|
||||
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\MigrateFieldInterface;
|
||||
|
||||
/**
|
||||
* The base class for all field plugins.
|
||||
*
|
||||
* @see \Drupal\migrate\Plugin\MigratePluginManager
|
||||
* @see \Drupal\migrate_drupal\Annotation\MigrateField
|
||||
* @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
|
||||
* @see plugin_api
|
||||
*
|
||||
* @ingroup migration
|
||||
*/
|
||||
abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface {
|
||||
|
||||
/**
|
||||
* {@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldType(Row $row) {
|
||||
$field_type = $row->getSourceProperty('type');
|
||||
|
||||
if (isset($this->pluginDefinition['type_map'][$field_type])) {
|
||||
return $this->pluginDefinition['type_map'][$field_type];
|
||||
}
|
||||
else {
|
||||
return $field_type;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_drupal\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "nodereference",
|
||||
* core = {6},
|
||||
* type_map = {
|
||||
* "nodereference" = "entity_reference",
|
||||
* },
|
||||
* )
|
||||
*/
|
||||
class NodeReference extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'iterator',
|
||||
'source' => $field_name,
|
||||
'process' => [
|
||||
'target_id' => [
|
||||
'plugin' => 'migration_lookup',
|
||||
'migration' => 'd6_node',
|
||||
'source' => 'nid',
|
||||
],
|
||||
],
|
||||
];
|
||||
$migration->setProcessOfProperty($field_name, $process);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -42953,6 +42953,15 @@ $connection->insert('taxonomy_vocabulary')
|
|||
'module' => 'taxonomy',
|
||||
'weight' => '0',
|
||||
))
|
||||
->values(array(
|
||||
'vid' => '4',
|
||||
'name' => 'vocabulary name much longer than thirty two characters',
|
||||
'machine_name' => 'vocabulary_name_much_longer_than_thirty_two_characters',
|
||||
'description' => 'description of vocabulary name much longer than thirty two characters',
|
||||
'hierarchy' => '1',
|
||||
'module' => 'taxonomy',
|
||||
'weight' => '0',
|
||||
))
|
||||
->execute();
|
||||
|
||||
$connection->schema()->createTable('tracker_node', array(
|
||||
|
@ -44319,6 +44328,14 @@ $connection->insert('variable')
|
|||
'name' => 'theme_settings',
|
||||
'value' => 'a:16:{s:11:"toggle_logo";i:0;s:11:"toggle_name";i:1;s:13:"toggle_slogan";i:0;s:24:"toggle_node_user_picture";i:0;s:27:"toggle_comment_user_picture";i:0;s:32:"toggle_comment_user_verification";i:0;s:14:"toggle_favicon";i:0;s:16:"toggle_main_menu";i:0;s:21:"toggle_secondary_menu";i:0;s:12:"default_logo";i:1;s:9:"logo_path";s:23:"public://customlogo.png";s:11:"logo_upload";s:0:"";s:15:"default_favicon";i:0;s:12:"favicon_path";s:24:"public://somefavicon.png";s:14:"favicon_upload";s:0:"";s:16:"favicon_mimetype";s:9:"image/png";}',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'theme_bartik_settings',
|
||||
'value' => 'a:18:{s:11:"toggle_logo";i:1;s:11:"toggle_name";i:1;s:13:"toggle_slogan";i:1;s:24:"toggle_node_user_picture";i:1;s:27:"toggle_comment_user_picture";i:1;s:32:"toggle_comment_user_verification";i:1;s:14:"toggle_favicon";i:1;s:16:"toggle_main_menu";i:1;s:21:"toggle_secondary_menu";i:1;s:12:"default_logo";i:0;s:9:"logo_path";s:16:"public://gnu.png";s:15:"default_favicon";i:1;s:12:"favicon_path";s:0:"";s:14:"favicon_upload";s:0:"";s:6:"scheme";s:7:"default";s:7:"palette";a:9:{s:3:"top";s:7:"#0779bf";s:6:"bottom";s:7:"#48a9e4";s:2:"bg";s:7:"#ffffff";s:7:"sidebar";s:7:"#f6f6f2";s:14:"sidebarborders";s:7:"#f9f9f9";s:6:"footer";s:7:"#292929";s:11:"titleslogan";s:7:"#fffeff";s:4:"text";s:7:"#3b3b3b";s:4:"link";s:7:"#0071B3";}s:5:"theme";s:6:"bartik";s:4:"info";a:12:{s:6:"fields";a:9:{s:3:"top";s:10:"Header top";s:6:"bottom";s:13:"Header bottom";s:2:"bg";s:15:"Main background";s:7:"sidebar";s:18:"Sidebar background";s:14:"sidebarborders";s:15:"Sidebar borders";s:6:"footer";s:17:"Footer background";s:11:"titleslogan";s:16:"Title and slogan";s:4:"text";s:10:"Text color";s:4:"link";s:10:"Link color";}s:7:"schemes";a:6:{s:7:"default";a:2:{s:5:"title";s:21:"Blue Lagoon (default)";s:6:"colors";a:9:{s:3:"top";s:7:"#0779bf";s:6:"bottom";s:7:"#48a9e4";s:2:"bg";s:7:"#ffffff";s:7:"sidebar";s:7:"#f6f6f2";s:14:"sidebarborders";s:7:"#f9f9f9";s:6:"footer";s:7:"#292929";s:11:"titleslogan";s:7:"#fffeff";s:4:"text";s:7:"#3b3b3b";s:4:"link";s:7:"#0071B3";}}s:9:"firehouse";a:2:{s:5:"title";s:9:"Firehouse";s:6:"colors";a:9:{s:3:"top";s:7:"#cd2d2d";s:6:"bottom";s:7:"#cf3535";s:2:"bg";s:7:"#ffffff";s:7:"sidebar";s:7:"#f1f4f0";s:14:"sidebarborders";s:7:"#ededed";s:6:"footer";s:7:"#1f1d1c";s:11:"titleslogan";s:7:"#fffeff";s:4:"text";s:7:"#3b3b3b";s:4:"link";s:7:"#d6121f";}}s:3:"ice";a:2:{s:5:"title";s:3:"Ice";s:6:"colors";a:9:{s:3:"top";s:7:"#d0d0d0";s:6:"bottom";s:7:"#c2c4c5";s:2:"bg";s:7:"#ffffff";s:7:"sidebar";s:7:"#ffffff";s:14:"sidebarborders";s:7:"#cccccc";s:6:"footer";s:7:"#24272c";s:11:"titleslogan";s:7:"#000000";s:4:"text";s:7:"#4a4a4a";s:4:"link";s:7:"#019dbf";}}s:4:"plum";a:2:{s:5:"title";s:4:"Plum";s:6:"colors";a:9:{s:3:"top";s:7:"#4c1c58";s:6:"bottom";s:7:"#593662";s:2:"bg";s:7:"#fffdf7";s:7:"sidebar";s:7:"#edede7";s:14:"sidebarborders";s:7:"#e7e7e7";s:6:"footer";s:7:"#2c2c28";s:11:"titleslogan";s:7:"#ffffff";s:4:"text";s:7:"#301313";s:4:"link";s:7:"#9d408d";}}s:5:"slate";a:2:{s:5:"title";s:5:"Slate";s:6:"colors";a:9:{s:3:"top";s:7:"#4a4a4a";s:6:"bottom";s:7:"#4e4e4e";s:2:"bg";s:7:"#ffffff";s:7:"sidebar";s:7:"#ffffff";s:14:"sidebarborders";s:7:"#d0d0d0";s:6:"footer";s:7:"#161617";s:11:"titleslogan";s:7:"#ffffff";s:4:"text";s:7:"#3b3b3b";s:4:"link";s:7:"#0073b6";}}s:0:"";a:2:{s:5:"title";s:6:"Custom";s:6:"colors";a:0:{}}}s:3:"css";a:1:{i:0;s:14:"css/colors.css";}s:4:"copy";a:1:{i:0;s:8:"logo.png";}s:9:"gradients";a:1:{i:0;a:3:{s:9:"dimension";a:4:{i:0;i:0;i:1;i:0;i:2;i:0;i:3;i:0;}s:9:"direction";s:8:"vertical";s:6:"colors";a:2:{i:0;s:3:"top";i:1;s:6:"bottom";}}}s:4:"fill";a:0:{}s:6:"slices";a:0:{}s:12:"blend_target";s:7:"#ffffff";s:11:"preview_css";s:17:"color/preview.css";s:10:"preview_js";s:16:"color/preview.js";s:12:"preview_html";s:18:"color/preview.html";s:10:"base_image";s:14:"color/base.png";}}',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'theme_seven_settings',
|
||||
'value' => 'a:15:{s:11:"toggle_logo";i:1;s:11:"toggle_name";i:1;s:13:"toggle_slogan";i:1;s:24:"toggle_node_user_picture";i:1;s:27:"toggle_comment_user_picture";i:0;s:32:"toggle_comment_user_verification";i:1;s:14:"toggle_favicon";i:1;s:16:"toggle_main_menu";i:1;s:21:"toggle_secondary_menu";i:0;s:12:"default_logo";i:1;s:9:"logo_path";s:0:"";s:11:"logo_upload";s:0:"";s:15:"default_favicon";i:1;s:12:"favicon_path";s:0:"";s:14:"favicon_upload";s:0:"";}',
|
||||
))
|
||||
->values(array(
|
||||
'name' => 'tracker_batch_size',
|
||||
'value' => 'i:999;',
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
name: 'Migrate field plugin manager test'
|
||||
type: module
|
||||
description: 'Example module demonstrating the field plugin manager in the Migrate API.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Module for Migrate Field Plugin Manager testing.
|
||||
*/
|
||||
|
||||
use Drupal\migrate_field_plugin_manager_test\Plugin\migrate\cckfield\d6\FileField;
|
||||
|
||||
function migrate_field_plugin_manager_test_migrate_field_info_alter(array &$definitions) {
|
||||
if (isset($definitions['filefield'])) {
|
||||
$definitions['filefield']['class'] = FileField::class;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_field_plugin_manager_test\Plugin\migrate\cckfield\d6;
|
||||
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\cckfield\CckFieldPluginBase;
|
||||
|
||||
/**
|
||||
* @MigrateCckField(
|
||||
* id = "filefield",
|
||||
* core = {6}
|
||||
* )
|
||||
*/
|
||||
class FileField extends CckFieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
$migration->mergeProcessOfProperty($field_name, [
|
||||
'class' => __CLASS__,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_field_plugin_manager_test\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "d6_file",
|
||||
* core = {6},
|
||||
* type_map = {
|
||||
* "file" = "file"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class D6FileField extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\migrate_field_plugin_manager_test\Plugin\migrate\field;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
use Drupal\migrate\Plugin\MigrationInterface;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "d6_no_core_version_specified"
|
||||
* )
|
||||
*/
|
||||
class D6NoCoreVersionSpecified extends FieldPluginBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel;
|
||||
|
||||
use Drupal\migrate_field_plugin_manager_test\Plugin\migrate\cckfield\d6\FileField;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class CckFieldBackwardsCompatibilityTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['file', 'migrate_field_plugin_manager_test'];
|
||||
|
||||
/**
|
||||
* Ensures that the cckfield backwards compatibility layer is invoked.
|
||||
*/
|
||||
public function testBackwardsCompatibility() {
|
||||
$migration = $this->container
|
||||
->get('plugin.manager.migration')
|
||||
->getDefinition('d6_node:story');
|
||||
|
||||
$this->assertSame(FileField::class, $migration['process']['field_test_filefield']['class']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
|
||||
/**
|
||||
* Tests the field plugin manager.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class MigrateFieldPluginManagerTest extends MigrateDrupalTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'user', 'field', 'migrate_drupal', 'options', 'file', 'text', 'migrate_field_plugin_manager_test'];
|
||||
|
||||
/**
|
||||
* Tests that the correct MigrateField plugins are used.
|
||||
*/
|
||||
public function testPluginSelection() {
|
||||
$plugin_manager = $this->container->get('plugin.manager.migrate.field');
|
||||
|
||||
try {
|
||||
// If this test passes, getPluginIdFromFieldType will raise a
|
||||
// PluginNotFoundException and we'll never reach fail().
|
||||
$plugin_manager->getPluginIdFromFieldType('filefield', ['core' => 7]);
|
||||
$this->fail('Expected Drupal\Component\Plugin\Exception\PluginNotFoundException.');
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
$this->assertIdentical($e->getMessage(), "Plugin ID 'filefield' was not found.");
|
||||
}
|
||||
|
||||
$this->assertIdentical('d6_file', $plugin_manager->getPluginIdFromFieldType('file', ['core' => 6]));
|
||||
|
||||
// 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]));
|
||||
|
||||
try {
|
||||
// If this test passes, getPluginIdFromFieldType will raise a
|
||||
// PluginNotFoundException and we'll never reach fail().
|
||||
$plugin_manager->getPluginIdFromFieldType('d6_no_core_version_specified', ['core' => 7]);
|
||||
$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.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests the variable multirow source plugin.
|
||||
*
|
||||
* @covers \Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableMultiRowTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['variable'] = [
|
||||
['name' => 'foo', 'value' => 'i:1;'],
|
||||
['name' => 'bar', 'value' => 'b:0;'],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'name' => 'foo',
|
||||
'value' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'bar',
|
||||
'value' => FALSE,
|
||||
],
|
||||
];
|
||||
|
||||
// The expected count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// The source plugin configuration.
|
||||
$tests[0]['configuration']['variables'] = [
|
||||
'foo',
|
||||
'bar',
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests the variable source plugin.
|
||||
*
|
||||
* @covers \Drupal\migrate_drupal\Plugin\migrate\source\Variable
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['variable'] = [
|
||||
['name' => 'foo', 'value' => 'i:1;'],
|
||||
['name' => 'bar', 'value' => 'b:0;'],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'id' => 'foo',
|
||||
'foo' => 1,
|
||||
'bar' => FALSE,
|
||||
],
|
||||
];
|
||||
|
||||
// The expected count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// The source plugin configuration.
|
||||
$tests[0]['configuration']['variables'] = [
|
||||
'foo',
|
||||
'bar',
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests the variable source plugin.
|
||||
*
|
||||
* @covers \Drupal\migrate_drupal\Plugin\migrate\source\d6\i18nVariable
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class i18nVariableTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['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";',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'language' => 'fr',
|
||||
'site_slogan' => 'Migrate est génial',
|
||||
'site_name' => 'nom de site',
|
||||
],
|
||||
[
|
||||
'language' => 'mi',
|
||||
'site_slogan' => 'Ko whakamataku heke',
|
||||
'site_name' => 'ingoa_pae',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// The migration configuration.
|
||||
$tests[0]['configuration']['variables'] = [
|
||||
'site_slogan',
|
||||
'site_name',
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,17 +33,18 @@ class MigrateDependenciesTest extends MigrateDrupal6TestBase {
|
|||
'd6_node:company',
|
||||
'd6_node:employee',
|
||||
'd6_node:event',
|
||||
'd6_node:forum',
|
||||
'd6_node:page',
|
||||
'd6_user',
|
||||
'd6_node_type',
|
||||
'd6_node_settings',
|
||||
'd6_filter_format',
|
||||
'd6_node:sponsor',
|
||||
'd6_node:story',
|
||||
'd6_node:test_event',
|
||||
'd6_node:test_page',
|
||||
'd6_node:test_planet',
|
||||
'd6_node:test_story',
|
||||
'd6_node_type',
|
||||
'd6_node_settings',
|
||||
'd6_filter_format',
|
||||
'd6_user',
|
||||
'd6_comment_type',
|
||||
'd6_comment_entity_display',
|
||||
'd6_comment_entity_form_display',
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
/**
|
||||
* Tests variable multirow source w/ high water handling.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableMultiRowSourceWithHighwaterTest extends VariableMultiRowTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->migrationConfiguration['highWaterProperty']['field'] = 'test';
|
||||
parent::setup();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\migrate_drupal\Unit\source;
|
||||
|
||||
/**
|
||||
* Tests D6 variable multirow source plugin.
|
||||
*
|
||||
* @group migrate_drupal
|
||||
*/
|
||||
class VariableMultiRowTest extends VariableMultiRowTestBase {
|
||||
|
||||
}
|
Reference in a new issue