function PathValidator::getPathAttributes
Same name in other branches
- 9 core/lib/Drupal/Core/Path/PathValidator.php \Drupal\Core\Path\PathValidator::getPathAttributes()
- 10 core/lib/Drupal/Core/Path/PathValidator.php \Drupal\Core\Path\PathValidator::getPathAttributes()
- 11.x 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\PathCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.