function SkippablePathBasedBreadcrumbBuilder::applies

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/menu_test/src/SkippablePathBasedBreadcrumbBuilder.php \Drupal\menu_test\SkippablePathBasedBreadcrumbBuilder::applies()

Whether this breadcrumb builder should be used to build the breadcrumb.

@todo Uncomment new method parameters before drupal:12.0.0, see https://www.drupal.org/project/drupal/issues/3459277.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match. phpcs:ignore Drupal.Commenting.FunctionComment.ParamNameNoMatch

\Drupal\Core\Cache\CacheableMetadata $cacheable_metadata: The cacheable metadata to add to if your check varies by or depends on something. Anything you specify here does not have to be repeated in the build() method as it will be merged in automatically.

Return value

bool TRUE if this builder should be used or FALSE to let other builders decide.

Overrides BreadcrumbBuilderInterface::applies

File

core/modules/system/tests/modules/menu_test/src/SkippablePathBasedBreadcrumbBuilder.php, line 26

Class

SkippablePathBasedBreadcrumbBuilder
A path-based breadcrumb builder can be skipped from applying.

Namespace

Drupal\menu_test

Code

public function applies(RouteMatchInterface $route_match, ?CacheableMetadata $cacheable_metadata = NULL) : bool {
  $query_arg = 'menu_test_skip_breadcrumbs';
  $cacheable_metadata?->addCacheContexts([
    'url.query_args:' . $query_arg,
  ]);
  // Apply unless the query argument is present.
  return !$this->requestStack
    ->getCurrentRequest()->query
    ->has($query_arg);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.