Skip to content

Commit

Permalink
Allow D8 link handler to work with named field properties
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisolof committed Oct 15, 2024
1 parent 5a92b22 commit 73c4c8e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Drupal/Driver/Fields/Drupal8/LinkHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ class LinkHandler extends AbstractHandler {
* {@inheritdoc}
*/
public function expand($values) {
$return = [];
$return_values = [];
foreach ($values as $value) {
// 'options' is required to be an array, otherwise the utility class
// Drupal\Core\Utility\UnroutedUrlAssembler::assemble() will complain.
$options = [];
if (!empty($value[2])) {
parse_str($value[2], $options);
}
$return[] = [
'options' => $options,
'title' => $value[0],
'uri' => $value[1],
$return_value = [
'title' => $value['title'] ?? $value[0] ?? NULL,
'uri' => $value['uri'] ?? $value[1] ?? NULL,
'options' => [],
];
$options = $value['options'] ?? $value[2] ?? NULL;
if ($options) {
parse_str($options, $return_value['options']);
}
$return_values[] = $return_value;
}
return $return;
return $return_values;
}

}

0 comments on commit 73c4c8e

Please sign in to comment.