getCurrentLanguage(); $result = $variables['result']; $variables['url'] = UrlHelper::stripDangerousProtocols($result['link']); $variables['title'] = $result['title']; if (isset($result['langcode']) && $result['langcode'] != $language_interface->getId() && $result['langcode'] != LanguageInterface::LANGCODE_NOT_SPECIFIED) { $variables['title_attributes']['lang'] = $result['langcode']; $variables['content_attributes']['lang'] = $result['langcode']; } $info = []; if (!empty($result['plugin_id'])) { $info['plugin_id'] = $result['plugin_id']; } if (!empty($result['user'])) { $info['user'] = $result['user']; } if (!empty($result['date'])) { $info['date'] = \Drupal::service('date.formatter')->format($result['date'], 'short'); } if (isset($result['extra']) && is_array($result['extra'])) { $info = array_merge($info, $result['extra']); } // Check for existence. User search does not include snippets. $variables['snippet'] = $result['snippet'] ?? ''; // Provide separated and grouped meta information.. $variables['info_split'] = $info; $variables['info'] = [ '#type' => 'inline_template', '#template' => '{{ info|safe_join(" - ") }}', '#context' => ['info' => $info], ]; }