Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #2975461 by quietone, Matroskeen, Lendude: Convert query string…
… to array for d6 menu_link migration
- Loading branch information
catch
committed
Nov 8, 2021
1 parent
253a0bb
commit 1ae88e0
Showing
6 changed files
with
63 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
modules/menu_link_content/src/Plugin/migrate/process/LinkOptions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters