diff core/profiles/demo_umami/themes/umami/umami.theme @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
line wrap: on
line diff
--- a/core/profiles/demo_umami/themes/umami/umami.theme	Thu Feb 28 13:11:55 2019 +0000
+++ b/core/profiles/demo_umami/themes/umami/umami.theme	Thu May 09 15:34:47 2019 +0100
@@ -7,7 +7,7 @@
 
 use Drupal\Component\Utility\Html;
 use Drupal\Core\Form\FormStateInterface;
-use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\search\SearchPageInterface;
 
 /**
  * Implements hook_preprocess_HOOK() for HTML document templates.
@@ -68,19 +68,18 @@
 function umami_preprocess_breadcrumb(&$variables) {
   // We are creating a variable for the Current Page Title, to allow us to print
   // it after the breadcrumbs loop has run.
-  $request = \Drupal::request();
-  if ($route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) {
-    // Search page titles aren't resolved using the title_resolver service - it
-    // will always return 'Search' instead of 'Search for [term]', which would
-    // give us a breadcrumb of Home >> Search >> Search.
-    // @see https://www.drupal.org/project/drupal/issues/2359901
-    // @see https://www.drupal.org/project/drupal/issues/2403359
-    if (($entity = $request->attributes->get('entity')) && $entity->getEntityTypeId() === 'search_page') {
-      $variables['current_page_title'] = $entity->getPlugin()->suggestedTitle();
-    }
-    else {
-      $variables['current_page_title'] = \Drupal::service('title_resolver')->getTitle($request, $route);
-    }
+  $route_match = \Drupal::routeMatch();
+  // Search page titles aren't resolved using the title_resolver service - it
+  // will always return 'Search' instead of 'Search for [term]', which would
+  // give us a breadcrumb of Home >> Search >> Search.
+  // @todo Revisit after https://www.drupal.org/project/drupal/issues/2359901
+  // @todo Revisit after https://www.drupal.org/project/drupal/issues/2403359
+  $entity = $route_match->getParameter('entity');
+  if ($entity instanceof SearchPageInterface) {
+    $variables['current_page_title'] = $entity->getPlugin()->suggestedTitle();
+  }
+  else {
+    $variables['current_page_title'] = \Drupal::service('title_resolver')->getTitle(\Drupal::request(), $route_match->getRouteObject());
   }
   // Since we are printing the 'Current Page Title', add the URL cache context.
   // If we don't, then we might end up with something like