Commit de0a575d authored by catch's avatar catch
Browse files

Issue #2061911 by AlexandrTodorozhko, jibran, dawehner: Remove...

Issue #2061911 by AlexandrTodorozhko, jibran, dawehner: Remove drupal_set_breadcrumb() and LegacyBreadcrumbBuilder in taxonomy module.
parent 13ce7999
<?php
/**
* @file
* Contains of \Drupal\taxonomy\TermBreadcrumbBuilder.
*/
namespace Drupal\taxonomy;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderBase;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
/**
* Provides a custom taxonomy breadcrumb builder that uses the term hierarchy.
*/
class TermBreadcrumbBuilder extends BreadcrumbBuilderBase {
/**
* {@inheritdoc}
*/
public function build(array $attributes) {
if (!empty($attributes[RouteObjectInterface::ROUTE_NAME]) && $attributes[RouteObjectInterface::ROUTE_NAME] == 'taxonomy.term_page' && ($term = $attributes['taxonomy_term']) && $term instanceof TermInterface) {
// @todo This overrides any other possible breadcrumb and is a pure
// hard-coded presumption. Make this behavior configurable per
// vocabulary or term.
$breadcrumb = array();
while ($parents = taxonomy_term_load_parents($term->id())) {
$term = array_shift($parents);
$breadcrumb[] = $this->l($term->label(), 'taxonomy.term_page', array('taxonomy_term' => $term->id()));
}
$breadcrumb[] = $this->l($this->t('Home'), '<front>');
$breadcrumb = array_reverse($breadcrumb);
return $breadcrumb;
}
}
}
......@@ -19,17 +19,6 @@ function taxonomy_term_page(Term $term) {
// Assign the term name as the page title.
drupal_set_title($term->label());
// @todo This overrides any other possible breadcrumb and is a pure hard-coded
// presumption. Make this behavior configurable per vocabulary or term.
$breadcrumb = array();
$current = $term;
while ($parents = taxonomy_term_load_parents($current->id())) {
$current = array_shift($parents);
$breadcrumb[] = l($current->label(), 'taxonomy/term/' . $current->id());
}
$breadcrumb[] = l(t('Home'), NULL);
$breadcrumb = array_reverse($breadcrumb);
drupal_set_breadcrumb($breadcrumb);
drupal_add_feed('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->label());
foreach ($term->uriRelationships() as $rel) {
......
services:
taxonomy_term.breadcrumb:
class: Drupal\taxonomy\TermBreadcrumbBuilder
tags:
- { name: breadcrumb_builder, priority: 1002 }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment