You are here

public function WebformRequest::isWebformAdminRoute in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/WebformRequest.php \Drupal\webform\WebformRequest::isWebformAdminRoute()

Determine if the current request is a webform admin route.

Return value

bool TRUE if the current request is a webform admin route.

Overrides WebformRequestInterface::isWebformAdminRoute

File

src/WebformRequest.php, line 118

Class

WebformRequest
Handles webform requests.

Namespace

Drupal\webform

Code

public function isWebformAdminRoute() {
  if (isset($this->isAdminRoute)) {
    return $this->isAdminRoute;
  }

  // Make sure the current route is an admin route.
  if (!$this->adminContext
    ->isAdminRoute()) {
    $this->isAdminRoute = FALSE;
    return $this->isAdminRoute;
  }
  $route_name = $this->routeMatch
    ->getRouteName();
  if (in_array($route_name, [
    'entity.webform.canonical',
    'entity.webform_submission.edit_form',
  ])) {
    $this->isAdminRoute = FALSE;
  }
  else {
    $this->isAdminRoute = preg_match('/^(webform\\.|^entity\\.([^.]+\\.)?webform)/', $route_name) ? TRUE : FALSE;
  }
  return $this->isAdminRoute;
}