From 73c4c8e5b5b3ef2f95182bc8864087bf28c6bc22 Mon Sep 17 00:00:00 2001 From: "Christopher O. Caldwell" Date: Tue, 15 Oct 2024 16:41:32 -0600 Subject: [PATCH] Allow D8 link handler to work with named field properties gh-192 --- .../Driver/Fields/Drupal8/LinkHandler.php | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Drupal/Driver/Fields/Drupal8/LinkHandler.php b/src/Drupal/Driver/Fields/Drupal8/LinkHandler.php index a6c87bf..d7d5fe9 100644 --- a/src/Drupal/Driver/Fields/Drupal8/LinkHandler.php +++ b/src/Drupal/Driver/Fields/Drupal8/LinkHandler.php @@ -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; } }