Skip to content
Snippets Groups Projects
Commit 55a804ce authored by catch's avatar catch
Browse files

Issue #2975461 by quietone, Matroskeen, Lendude: Convert query string to array...

Issue #2975461 by quietone, Matroskeen, Lendude: Convert query string to array for d6 menu_link migration
parent 84ef68cf
No related branches found
No related tags found
32 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!1896Issue #2940605: Can only intentionally re-render an entity with references 20 times,!1459Issue #3087632: menu_name max length is too long,!1398Issue #3186992 by hinal05, djsagar, kiran.kadam911, hitvika_verma,...,!1283Issue #2922435: "Add new comment" and "@count comments" links are not following accessibility good practices,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1254Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS,!1213Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1185Issue 318778: Rerolled patch.,!1162Issue #3100350: Unable to save '/' root path alias,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!1018Issue #2793343: Dialog drupalAutoButtons option should be respected on initial load,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display,!878Issue #3221534: throw an exception when IDs passed to loadMultiple() are badly formed,!877Issue #2708101: Default value for link text is not saved,!873Issue #2875228: Site install not using batch API service,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!844Resolve #3036010 "Updaters",!8293023322 - Contextual Links Style Update,!712Issue #2909128: Autocomplete intermittent on Chrome Android,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!449Issue #2784233: Allow multiple vocabularies in the taxonomy filter,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -27,7 +27,9 @@ process:
'link/uri':
plugin: link_uri
source: link_path
'link/options': options
'link/options':
plugin: link_options
source: options
route:
plugin: route
source:
......
<?php
namespace Drupal\menu_link_content\Plugin\migrate\process;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row;
/**
* Converts links options.
*
* Examples:
*
* @code
* process:
* link/options:
* plugin: link_options
* source: options
* @endcode
*
* This will convert the query options of the link.
*
* @MigrateProcessPlugin(
* id = "link_options",
* handle_multiples = TRUE
* )
*/
class LinkOptions extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (isset($value['query'])) {
// If the query parameters are stored as a string (as in D6), convert it
// into an array.
if (is_string($value['query'])) {
parse_str($value['query'], $old_query);
}
else {
$old_query = $value['query'];
}
$value['query'] = $old_query;
}
return $value;
}
}
......@@ -89,7 +89,7 @@ protected function assertEntity($id, $title, $menu, $description, $enabled, $exp
*/
public function testMenuLinks() {
$this->assertEntity('138', 'Test 1', 'secondary-links', 'Test menu link 1', TRUE, FALSE, ['attributes' => ['title' => 'Test menu link 1'], 'langcode' => 'en'], 'internal:/user/login', -50);
$this->assertEntity('139', 'Test 2', 'secondary-links', 'Test menu link 2', TRUE, TRUE, ['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], 'internal:/admin', -49);
$this->assertEntity('139', 'Test 2', 'secondary-links', 'Test menu link 2', TRUE, TRUE, ['query' => ['foo' => 'bar'], 'attributes' => ['title' => 'Test menu link 2']], 'internal:/admin', -49);
$this->assertEntity('140', 'Drupal.org', 'secondary-links', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'https://www.drupal.org', -50);
// Assert that missing title attributes don't stop or break migration.
......
......@@ -53,7 +53,7 @@ public function testMenuLinks() {
$this->assertSame('secondary-links', $menu_link->getMenuName());
$this->assertTrue($menu_link->isEnabled());
$this->assertTrue($menu_link->isExpanded());
$this->assertSame(['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
$this->assertSame(['query' => ['foo' => 'bar'], 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
$this->assertSame('internal:/admin', $menu_link->link->uri);
$this->assertSame(-49, $menu_link->getWeight());
......@@ -64,7 +64,7 @@ public function testMenuLinks() {
$this->assertSame('secondary-links', $menu_link->getMenuName());
$this->assertTrue($menu_link->isEnabled());
$this->assertTrue($menu_link->isExpanded());
$this->assertSame(['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
$this->assertSame(['query' => ['foo' => 'bar'], 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
$this->assertSame('internal:/admin', $menu_link->link->uri);
$this->assertSame(-49, $menu_link->getWeight());
......
......@@ -70,7 +70,14 @@ public function testMenuLinks() {
$this->assertEntity(245, 'und', 'Home', 'main', NULL, TRUE, FALSE, [], 'internal:/', 0);
$this->assertEntity(478, 'und', 'custom link test', 'admin', NULL, TRUE, FALSE, ['attributes' => ['title' => '']], 'internal:/admin/content', 0);
$this->assertEntity(479, 'und', 'node link test', 'tools', 'node 2', TRUE, FALSE, ['attributes' => ['title' => 'node 2']], 'entity:node/2', 3);
$this->assertEntity(479, 'und', 'node link test', 'tools', 'node 2', TRUE, FALSE, [
'attributes' => ['title' => 'node 2'],
'query' => [
'name' => 'ferret',
'color' => 'purple',
],
],
'entity:node/2', 3);
$menu_link_tree_service = \Drupal::service('menu.link_tree');
$parameters = new MenuTreeParameters();
......
......@@ -34445,7 +34445,7 @@
'link_path' => 'node/2',
'router_path' => 'node/%',
'link_title' => 'node link test',
'options' => 'a:1:{s:10:"attributes";a:1:{s:5:"title";s:6:"node 2";}}',
'options' => 'a:2:{s:10:"attributes";a:1:{s:5:"title";s:6:"node 2";}s:5:"query";a:2:{s:4:"name";s:6:"ferret";s:5:"color";s:6:"purple";}}',
'module' => 'menu',
'hidden' => '0',
'external' => '0',
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