You are here

protected function PathValidator::getPathAttributes in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Path/PathValidator.php \Drupal\Core\Path\PathValidator::getPathAttributes()

Gets the matched attributes for a given path.

Parameters

string $path: The path to check.

\Symfony\Component\HttpFoundation\Request $request: A request object with the given path.

bool $access_check: If FALSE then skip access check and check only whether the path is valid.

Return value

array|bool An array of request attributes of FALSE if an exception was thrown.

1 call to PathValidator::getPathAttributes()
PathValidator::getUrl in core/lib/Drupal/Core/Path/PathValidator.php
Helper for getUrlIfValid() and getUrlIfValidWithoutAccessCheck().

File

core/lib/Drupal/Core/Path/PathValidator.php, line 148

Class

PathValidator
Provides a default path validator and access checker.

Namespace

Drupal\Core\Path

Code

protected function getPathAttributes($path, Request $request, $access_check) {
  if (!$access_check || $this->account
    ->hasPermission('link to any page')) {
    $router = $this->accessUnawareRouter;
  }
  else {
    $router = $this->accessAwareRouter;
  }
  $initial_request_context = $router
    ->getContext() ? $router
    ->getContext() : new RequestContext();
  $path = $this->pathProcessor
    ->processInbound('/' . $path, $request);
  try {
    $request_context = new RequestContext();
    $request_context
      ->fromRequest($request);
    $router
      ->setContext($request_context);
    $result = $router
      ->match($path);
  } catch (ResourceNotFoundException $e) {
    $result = FALSE;
  } catch (ParamNotConvertedException $e) {
    $result = FALSE;
  } catch (AccessDeniedHttpException $e) {
    $result = FALSE;
  } catch (MethodNotAllowedException $e) {
    $result = FALSE;
  }
  $router
    ->setContext($initial_request_context);
  return $result;
}