Created
December 15, 2015 13:19
-
-
Save zviryatko/cd15bd0ce3ad3c9cf89d to your computer and use it in GitHub Desktop.
Add title to breadcrumbs in Drupal 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_process_HOOK(). | |
*/ | |
function custom_preprocess_breadcrumb(&$variables) { | |
/** @var \Drupal\Core\Controller\TitleResolverInterface $title_resolver */ | |
$title_resolver = \Drupal::service('title_resolver'); | |
/** @var \Drupal\Core\Routing\CurrentRouteMatch $current_route */ | |
$current_route = \Drupal::service('current_route_match'); | |
$title = $title_resolver->getTitle(\Drupal::request(), $current_route->getRouteObject()); | |
$variables['breadcrumb'][] = ['text' => (string) $title]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment