Skip to content
Snippets Groups Projects
Commit 8724f40e authored by snater's avatar snater
Browse files

Issue #3368287 by Snater: Remove deprecated D7 migration procedures

parent 9208bbe0
No related branches found
No related tags found
No related merge requests found
......@@ -1046,13 +1046,6 @@ function insert_help($route_name) {
* Implements hook_migration_plugins_alter().
*/
function insert_migration_plugins_alter(array &$migrations) {
if (
!empty($migrations['d7_field_instance_widget_insert_settings']) &&
!MigrateInsertWidgetSettings::standaloneMigrationIsOmittable()
) {
return;
}
unset($migrations['d7_field_instance_widget_insert_settings']);
$field_instance_widget_settings_migrations = array_filter(
......
<?php
namespace Drupal\insert\Plugin\migrate\destination;
use Drupal\migrate\Plugin\migrate\destination\PerComponentEntityFormDisplay;
use Drupal\migrate\Row;
@trigger_error(
"The Drupal\insert\Plugin\migrate\destination\PerComponentEntityFormDisplayInsert migrate destination plugin is deprecated in insert:8.x-2.0-beta4 and is removed in insert:8.x-3.0. Insert settings migrations are merged into Drupal core's 'd7_field_instance_widget_settings' migration. See https://drupal.org/node/123",
E_USER_DEPRECATED
);
/**
* This class imports Insert module field settings of an entity form display.
*
* @see \Drupal\migrate\Plugin\migrate\destination\PerComponentEntityFormDisplay
*
* @deprecated in insert:8.x-2.0-beta4 and is removed in insert:8.x-3.0. There
* is no replacement.
*
* @MigrateDestination(
* id = "component_entity_form_display_insert"
* )
*/
class PerComponentEntityFormDisplayInsert extends PerComponentEntityFormDisplay {
/**
* @inheritdoc
*/
public function import(Row $row, array $old_destination_id_values = []) {
$values = [];
foreach (array_keys($this->getIds()) as $id) {
$values[$id] = $row->getDestinationProperty($id);
}
$entity = $this->getEntity($values['entity_type'], $values['bundle'], $values[static::MODE_NAME]);
$insert_settings = $row->getDestinationProperty('options/third_party_settings/insert');
// Add Insert module third party settings to field settings:
if ($insert_settings && $field_component = $entity->getComponent($values['field_name'])) {
$field_component['third_party_settings']['insert'] = $insert_settings;
$entity->setComponent($values['field_name'], $field_component);
}
$entity->save();
return array_values($values);
}
}
<?php
namespace Drupal\insert\Plugin\migrate\process;
use Drupal\insert\Utility\MigrateInsertWidgetSettings;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
@trigger_error(
"The Drupal\insert\Plugin\migrate\process\FieldInstanceWidgetInsertSettings migrate process plugin is deprecated in insert:8.x-2.0-beta4 and is removed in insert:8.x-3.0. Insert settings migrations are merged into Drupal core's 'd7_field_instance_widget_settings' migration. See https://drupal.org/node/123",
E_USER_DEPRECATED
);
/**
* Gets the field instance widget's Insert module specific settings.
*
* @deprecated in insert:8.x-2.0-beta4 and is removed in insert:8.x-3.0. There
* is no replacement.
*
* @MigrateProcessPlugin(
* id = "field_instance_widget_insert_settings",
* handle_multiples = TRUE
* )
*/
class FieldInstanceWidgetInsertSettings extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
return $this->getInsertSettings($value);
}
/**
* Merges the default D8 and specified D7 Insert module settings for a widget
* type.
*
* @param array $widget_settings
* The widget settings from D7 for this widget.
*
* @return array[]
*/
public function getInsertSettings(array $widget_settings) {
$insert = MigrateInsertWidgetSettings::getInsertWidgetSettings($widget_settings);
return ['insert' => $insert];
}
}
......@@ -9,47 +9,6 @@ use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
*/
class MigrateInsertWidgetSettings {
/**
* Determines whether the standalone insert settings migration can be skipped.
*
* We migrate Insert third party settings as part of Drupal core's
* "d7_field_instance_widget_settings" migration, with a
* migration_plugins_alter and with insert_migrate_prepare_row hook
* implementation. But before we remove the preexisting, standalone insert
* settings migration, we have to check if the map table of
* 'd7_field_instance_widget_insert_settings' is empty.
*
* @return bool
* Whether the standalone insert settings migration can be skipped.
*/
public static function standaloneMigrationIsOmittable(): bool {
$plugin_manager = \Drupal::service('plugin.manager.migration');
assert($plugin_manager instanceof MigrationPluginManagerInterface);
$standalone_migration = $plugin_manager->createStubMigration([
'id' => 'd7_field_instance_widget_insert_settings',
'source' => ['plugin' => 'd7_field_instance_per_form_display'],
'destination' => ['plugin' => 'null'],
]);
// The map table of 'd7_field_instance_widget_insert_settings' is not empty.
if ($standalone_migration->getIdMap()->processedCount() > 0) {
@trigger_error(
"The standalone Insert settings migration 'd7_field_instance_widget_insert_settings' is deprecated in insert:8.x-2.0-beta4 and is removed in insert:8.x-3.0. Insert settings migrations are merged into Drupal core's 'd7_field_instance_widget_settings' migration. See https://drupal.org/node/123",
E_USER_DEPRECATED
);
return FALSE;
}
// The map table of 'd7_field_instance_widget_insert_settings' is empty,
// which means:
// - It wasn't ever executed.
// - It was rolled back.
// - There are no Drupal 7 fields in the source database.
// All of the above means that the standalone insert settings migration can
// be ignored.
return TRUE;
}
/**
* Converts D7 field insert widget settings to Drupal 9 third party settings.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment