diff --git a/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php b/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php index 3bbb0df..dc5fbea 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php +++ b/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php @@ -47,28 +47,21 @@ public function __construct(EntityManager $entity_manager, ConfigFactory $config * {@inheritdoc} */ public function build(array $attributes) { - - // @todo This only works for legacy routes. Once node/% and forum/% are - // converted to the new router this code will need to be updated. - if (isset($attributes['drupal_menu_item'])) { + if ($attributes['_route'] == 'node_show') { + $node = $attributes['node']; + if (_forum_node_check_node_type($node)) { + $breadcrumb = $this->forumPostBreadcrumb($node); + } + } + // @todo This only works for legacy routes. Once forum/% is converted to the + // new router this code will need to be updated. + elseif (isset($attributes['drupal_menu_item'])) { $item = $attributes['drupal_menu_item']; - switch ($item['path']) { - - case 'node/%': - $node = $item['map'][1]; - // Load the object in case of missing wildcard loaders. - $node = is_object($node) ? $node : node_load($node); - if (_forum_node_check_node_type($node)) { - $breadcrumb = $this->forumPostBreadcrumb($node); - } - break; - - case 'forum/%': + if ($item['path'] == 'forum/%') { $term = $item['map'][1]; // Load the object in case of missing wildcard loaders. $term = is_object($term) ? $term : forum_forum_load($term); $breadcrumb = $this->forumTermBreadcrumb($term); - break; } }