You are here

public function ThemeNegotiator::applies in Dashboards with Layout Builder 8

Same name and namespace in other branches
  1. 2.0.x src/Theme/ThemeNegotiator.php \Drupal\dashboards\Theme\ThemeNegotiator::applies()

Whether this theme negotiator should be used to set the theme.

Parameters

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

Return value

bool TRUE if this negotiator should be used or FALSE to let other negotiators decide.

Overrides ThemeNegotiatorInterface::applies

File

src/Theme/ThemeNegotiator.php, line 56

Class

ThemeNegotiator
Dashboard theme negotiator.

Namespace

Drupal\dashboards\Theme

Code

public function applies(RouteMatchInterface $route_match) {
  if ($dashboard = $route_match
    ->getParameter('dashboard')) {
    if (is_object($dashboard) && $dashboard
      ->showAlwaysInFrontend()) {
      return FALSE;
    }
  }
  if ($this->user
    ->isAnonymous() || !$this->user
    ->hasPermission('view the administration theme')) {
    return FALSE;
  }
  if (in_array($route_match
    ->getRouteName(), [
    'entity.dashboard.canonical',
    'layout_builder.dashboards.view',
    'layout_builder.dashboards_override.view',
  ])) {
    return TRUE;
  }
  return FALSE;
}