diff --git a/src/EasyBreadcrumbBuilder.php b/src/EasyBreadcrumbBuilder.php index 8f143f60d4fa8ab867614034507cc5b93525099f..d371bfdfdadf628f2b4befadb8f8001fbb74b917 100644 --- a/src/EasyBreadcrumbBuilder.php +++ b/src/EasyBreadcrumbBuilder.php @@ -11,6 +11,7 @@ use Drupal\Core\Access\AccessManagerInterface; use Drupal\Core\Breadcrumb\Breadcrumb; use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface; use Drupal\Core\Cache\CacheableDependencyInterface; +use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Controller\TitleResolverInterface; use Drupal\Core\Entity\EntityInterface; @@ -244,7 +245,12 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface { /** * {@inheritdoc} */ - public function applies(RouteMatchInterface $route_match) { + public function applies(RouteMatchInterface $route_match, ?CacheableMetadata $cacheable_metadata = NULL) { + + // @todo Remove null safe operator in Drupal 12.0.0, see + // https://www.drupal.org/project/drupal/issues/3459277. + $cacheable_metadata?->addCacheContexts(['route', 'url.path', 'languages']); + $applies_admin_routes = $this->config->get(EasyBreadcrumbConstants::APPLIES_ADMIN_ROUTES); // If never set before ensure Applies to administration pages is on. @@ -447,6 +453,8 @@ class EasyBreadcrumbBuilder implements BreadcrumbBuilderInterface { } // Expire cache by languages and config changes. + // @todo Remove in Drupal 12.0.0, will be added from ::applies(). See + // https://www.drupal.org/project/drupal/issues/3459277 $breadcrumb->addCacheContexts(['route', 'url.path', 'languages']); // Expire cache context for config changes.