Commit f781cd93 authored by catch's avatar catch
Browse files

Issue #3472592 by smustgrave: Fix Book breadcrumb cacheability

(cherry picked from commit 5eb99caa)
parent 65a3907d
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageInterface;
@@ -70,7 +71,8 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Acc
  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
  public function applies(RouteMatchInterface $route_match, ?CacheableMetadata $cacheable_metadata = NULL) {
    $cacheable_metadata?->addCacheContexts(['route.book_navigation']);
    $node = $route_match->getParameter('node');
    return $node instanceof NodeInterface && !empty($node->book);
  }