Loading core/modules/migrate_drupal/tests/fixtures/drupal7.php +1 −1 Changes for core/modules/migrate_drupal/tests/fixtures/drupal7.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -44169,7 +44169,7 @@ )) ->values(array( 'name' => 'search_active_modules', 'value' => 'a:2:{s:4:"node";s:4:"node";s:4:"user";s:4:"user";}', 'value' => 'a:2:{s:4:"node";s:4:"node";s:4:"user";i:0;}', )) ->values(array( 'name' => 'search_and_or_limit', core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +5 −1 Changes for core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -394,7 +394,7 @@ class MigrateUpgradeForm extends ConfirmFormBase { 'source_module' => 'path', 'destination_module' => 'path', ], 'search_page' => [ 'd6_search_page' => [ 'source_module' => 'search', 'destination_module' => 'search', ], Loading @@ -402,6 +402,10 @@ class MigrateUpgradeForm extends ConfirmFormBase { 'source_module' => 'search', 'destination_module' => 'search', ], 'd7_search_page' => [ 'source_module' => 'search', 'destination_module' => 'search', ], 'd7_search_settings' => [ 'source_module' => 'search', 'destination_module' => 'search', Loading core/modules/search/migration_templates/search_page.yml→core/modules/search/migration_templates/d6_search_page.yml +3 −3 Changes for core/modules/search/migration_templates/d6_search_page.yml: 3 added lines, 3 removed lines. Original line number Diff line number Diff line id: search_page id: d6_search_page label: Search page configuration migration_tags: - Drupal 6 - Drupal 7 source: plugin: variable plugin: d6_search_page variables: - node_rank_comments - node_rank_promote Loading @@ -17,6 +16,7 @@ source: path: node plugin: node_search process: module: module id: 'constants/id' path: 'constants/path' plugin: 'constants/plugin' Loading core/modules/search/migration_templates/d7_search_page.yml 0 → 100644 +46 −0 Changes for core/modules/search/migration_templates/d7_search_page.yml: 46 added lines, 0 removed lines. Original line number Diff line number Diff line id: d7_search_page label: Search page configuration migration_tags: - Drupal 7 source: plugin: d7_search_page variables: - node_rank_comments - node_rank_promote - node_rank_relevance - node_rank_sticky - node_rank_views constants: suffix: _search process: module: module module_exists: - plugin: skip_on_empty method: row source: module_exists status: - plugin: static_map source: status map: node: true user: true 0: false id: - plugin: concat source: - module - 'constants/suffix' plugin: - plugin: concat source: - module - 'constants/suffix' path: module 'configuration/rankings': plugin: search_configuration_rankings destination: plugin: entity:search_page core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php +81 −0 Changes for core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php: 81 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,9 +2,15 @@ namespace Drupal\search\Plugin\migrate\destination; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\migrate\Plugin\migrate\destination\EntityConfigBase; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; /** * @MigrateDestination( Loading @@ -13,6 +19,78 @@ */ class EntitySearchPage extends EntityConfigBase { /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ protected $moduleHandler; /** * Constructs a new EntitySearchPage. * * @param array $configuration * A configuration array containing information about the plugin instance. * @param string $plugin_id * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. * @param MigrationInterface $migration * The migration. * @param EntityStorageInterface $storage * The storage for this entity type. * @param array $bundles * The list of bundles this entity type has. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory. * @param ModuleHandlerInterface $module_handler * The module handler. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $config_factory); $this->moduleHandler = $module_handler; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { $entity_type_id = static::getEntityTypeId($plugin_id); return new static( $configuration, $plugin_id, $plugin_definition, $migration, $container->get('entity.manager')->getStorage($entity_type_id), array_keys($container->get('entity.manager')->getBundleInfo($entity_type_id)), $container->get('language_manager'), $container->get('config.factory'), $container->get('module_handler') ); } /** * {@inheritdoc} */ public function import(Row $row, array $old_destination_id_values = array()) { if ($this->moduleHandler->moduleExists($row->getDestinationProperty('module'))) { parent::import($row, $old_destination_id_values); $id = $row->getDestinationProperty('id'); /** @var \Drupal\search\Entity\SearchPage $search_page */ $search_page = $this->storage->load($id); if ($row->getDestinationProperty('status')) { $search_page->enable()->save(); } else { $search_page->disable()->save(); } return [$id]; } return []; } /** * Updates the entity with the contents of a row. * Loading @@ -23,7 +101,10 @@ class EntitySearchPage extends EntityConfigBase { */ protected function updateEntity(EntityInterface $entity, Row $row) { $entity->setPlugin($row->getDestinationProperty('plugin')); // The user_search plugin does not have a setConfiguration() method. if (method_exists($entity->getPlugin(), 'setConfiguration')) { $entity->getPlugin()->setConfiguration($row->getDestinationProperty('configuration')); } } } Loading
core/modules/migrate_drupal/tests/fixtures/drupal7.php +1 −1 Changes for core/modules/migrate_drupal/tests/fixtures/drupal7.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -44169,7 +44169,7 @@ )) ->values(array( 'name' => 'search_active_modules', 'value' => 'a:2:{s:4:"node";s:4:"node";s:4:"user";s:4:"user";}', 'value' => 'a:2:{s:4:"node";s:4:"node";s:4:"user";i:0;}', )) ->values(array( 'name' => 'search_and_or_limit',
core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +5 −1 Changes for core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -394,7 +394,7 @@ class MigrateUpgradeForm extends ConfirmFormBase { 'source_module' => 'path', 'destination_module' => 'path', ], 'search_page' => [ 'd6_search_page' => [ 'source_module' => 'search', 'destination_module' => 'search', ], Loading @@ -402,6 +402,10 @@ class MigrateUpgradeForm extends ConfirmFormBase { 'source_module' => 'search', 'destination_module' => 'search', ], 'd7_search_page' => [ 'source_module' => 'search', 'destination_module' => 'search', ], 'd7_search_settings' => [ 'source_module' => 'search', 'destination_module' => 'search', Loading
core/modules/search/migration_templates/search_page.yml→core/modules/search/migration_templates/d6_search_page.yml +3 −3 Changes for core/modules/search/migration_templates/d6_search_page.yml: 3 added lines, 3 removed lines. Original line number Diff line number Diff line id: search_page id: d6_search_page label: Search page configuration migration_tags: - Drupal 6 - Drupal 7 source: plugin: variable plugin: d6_search_page variables: - node_rank_comments - node_rank_promote Loading @@ -17,6 +16,7 @@ source: path: node plugin: node_search process: module: module id: 'constants/id' path: 'constants/path' plugin: 'constants/plugin' Loading
core/modules/search/migration_templates/d7_search_page.yml 0 → 100644 +46 −0 Changes for core/modules/search/migration_templates/d7_search_page.yml: 46 added lines, 0 removed lines. Original line number Diff line number Diff line id: d7_search_page label: Search page configuration migration_tags: - Drupal 7 source: plugin: d7_search_page variables: - node_rank_comments - node_rank_promote - node_rank_relevance - node_rank_sticky - node_rank_views constants: suffix: _search process: module: module module_exists: - plugin: skip_on_empty method: row source: module_exists status: - plugin: static_map source: status map: node: true user: true 0: false id: - plugin: concat source: - module - 'constants/suffix' plugin: - plugin: concat source: - module - 'constants/suffix' path: module 'configuration/rankings': plugin: search_configuration_rankings destination: plugin: entity:search_page
core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php +81 −0 Changes for core/modules/search/src/Plugin/migrate/destination/EntitySearchPage.php: 81 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2,9 +2,15 @@ namespace Drupal\search\Plugin\migrate\destination; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\migrate\Plugin\migrate\destination\EntityConfigBase; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; /** * @MigrateDestination( Loading @@ -13,6 +19,78 @@ */ class EntitySearchPage extends EntityConfigBase { /** * The module handler. * * @var \Drupal\Core\Extension\ModuleHandlerInterface */ protected $moduleHandler; /** * Constructs a new EntitySearchPage. * * @param array $configuration * A configuration array containing information about the plugin instance. * @param string $plugin_id * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. * @param MigrationInterface $migration * The migration. * @param EntityStorageInterface $storage * The storage for this entity type. * @param array $bundles * The list of bundles this entity type has. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory. * @param ModuleHandlerInterface $module_handler * The module handler. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $language_manager, $config_factory); $this->moduleHandler = $module_handler; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { $entity_type_id = static::getEntityTypeId($plugin_id); return new static( $configuration, $plugin_id, $plugin_definition, $migration, $container->get('entity.manager')->getStorage($entity_type_id), array_keys($container->get('entity.manager')->getBundleInfo($entity_type_id)), $container->get('language_manager'), $container->get('config.factory'), $container->get('module_handler') ); } /** * {@inheritdoc} */ public function import(Row $row, array $old_destination_id_values = array()) { if ($this->moduleHandler->moduleExists($row->getDestinationProperty('module'))) { parent::import($row, $old_destination_id_values); $id = $row->getDestinationProperty('id'); /** @var \Drupal\search\Entity\SearchPage $search_page */ $search_page = $this->storage->load($id); if ($row->getDestinationProperty('status')) { $search_page->enable()->save(); } else { $search_page->disable()->save(); } return [$id]; } return []; } /** * Updates the entity with the contents of a row. * Loading @@ -23,7 +101,10 @@ class EntitySearchPage extends EntityConfigBase { */ protected function updateEntity(EntityInterface $entity, Row $row) { $entity->setPlugin($row->getDestinationProperty('plugin')); // The user_search plugin does not have a setConfiguration() method. if (method_exists($entity->getPlugin(), 'setConfiguration')) { $entity->getPlugin()->setConfiguration($row->getDestinationProperty('configuration')); } } }