You are here

public function EasyBreadcrumbBuilder::applies in Easy Breadcrumb 8

Same name and namespace in other branches
  1. 2.x src/EasyBreadcrumbBuilder.php \Drupal\easy_breadcrumb\EasyBreadcrumbBuilder::applies()

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

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

Return value

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

Overrides BreadcrumbBuilderInterface::applies

File

src/EasyBreadcrumbBuilder.php, line 238

Class

EasyBreadcrumbBuilder
Primary implementation for the Easy Breadcrumb builder.

Namespace

Drupal\easy_breadcrumb

Code

public function applies(RouteMatchInterface $route_match) {
  $applies_admin_routes = $this->config
    ->get(EasyBreadcrumbConstants::APPLIES_ADMIN_ROUTES);

  // If never set before ensure Applies to administration pages is on.
  if (!isset($applies_admin_routes)) {
    return TRUE;
  }
  $request = $this->requestStack
    ->getCurrentRequest();
  $route = $request->attributes
    ->get(RouteObjectInterface::ROUTE_OBJECT);
  if ($route && $route
    ->getOption('_admin_route') && $applies_admin_routes == FALSE) {
    return FALSE;
  }
  return TRUE;
}