class PrettyPathBreadcrumb in Facets Pretty Paths 8
Pretty Paths breadcrumb builder.
Hierarchy
- class \Drupal\facets_pretty_paths\PrettyPathBreadcrumb implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of PrettyPathBreadcrumb
1 string reference to 'PrettyPathBreadcrumb'
1 service uses PrettyPathBreadcrumb
File
- src/
PrettyPathBreadcrumb.php, line 15
Namespace
Drupal\facets_pretty_pathsView source
class PrettyPathBreadcrumb implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
if ($route_match
->getParameter('facets_query')) {
return TRUE;
}
return FALSE;
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$breadcrumb
->addCacheContexts([
'route',
]);
$route_object = $route_match
->getRouteObject();
$route_without_facets_query = explode('/{facets_query}', $route_object
->getPath())[0];
$request = \Drupal::request();
$title = \Drupal::service('title_resolver')
->getTitle($request, $route_object);
$url = Url::fromUserInput($route_without_facets_query);
$links[] = Link::createFromRoute($this
->t('Home'), '<front>');
$links[] = Link::fromTextAndUrl($title, $url);
return $breadcrumb
->setLinks($links);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PrettyPathBreadcrumb:: |
public | function |
Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
PrettyPathBreadcrumb:: |
public | function |
Builds the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |