| Conditions | 6 |
| Paths | 7 |
| Total Lines | 33 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | public function expand($values) { |
||
| 14 | $return = array(); |
||
| 15 | foreach ($values as $value) { |
||
| 16 | $uri = $value[1]; |
||
| 17 | |||
| 18 | // If the uri has no scheme (and is not protocol relative) attempt to find |
||
| 19 | // a node with that label. |
||
| 20 | if (empty($uri_parts['scheme']) && strpos($uri, '//') !== 0) { |
||
| 21 | $entity_type_id = 'node'; |
||
| 22 | $query = \Drupal::entityQuery($entity_type_id)->condition('title', $uri); |
||
| 23 | $entities = $query->execute(); |
||
| 24 | if (!empty($entities)) { |
||
| 25 | $nid = array_shift($entities); |
||
| 26 | $uri = 'entity:' . $entity_type_id . '/' . $nid; |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | // 'options' is required to be an array, otherwise the utility class |
||
| 31 | // Drupal\Core\Utility\UnroutedUrlAssembler::assemble() will complain. |
||
| 32 | $options = array(); |
||
| 33 | if (!empty($value[2])) { |
||
| 34 | parse_str($value[2], $options); |
||
| 35 | } |
||
| 36 | |||
| 37 | $return[] = array( |
||
| 38 | 'options' => $options, |
||
| 39 | 'title' => $value[0], |
||
| 40 | 'uri' => $uri, |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | return $return; |
||
| 45 | } |
||
| 46 | |||
| 48 |