Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Routing/AccessAwareRouter.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
2 | 2 |
3 namespace Drupal\Core\Routing; | 3 namespace Drupal\Core\Routing; |
4 | 4 |
5 use Drupal\Core\Access\AccessManagerInterface; | 5 use Drupal\Core\Access\AccessManagerInterface; |
6 use Drupal\Core\Access\AccessResultReasonInterface; | 6 use Drupal\Core\Access\AccessResultReasonInterface; |
7 use Drupal\Core\Cache\CacheableDependencyInterface; | |
8 use Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException; | |
7 use Drupal\Core\Session\AccountInterface; | 9 use Drupal\Core\Session\AccountInterface; |
8 use Symfony\Component\HttpFoundation\Request; | 10 use Symfony\Component\HttpFoundation\Request; |
9 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; | 11 use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; |
10 use Symfony\Component\Routing\Matcher\RequestMatcherInterface; | 12 use Symfony\Component\Routing\Matcher\RequestMatcherInterface; |
11 use Symfony\Component\Routing\RequestContext as SymfonyRequestContext; | 13 use Symfony\Component\Routing\RequestContext as SymfonyRequestContext; |
32 protected $accessManager; | 34 protected $accessManager; |
33 | 35 |
34 /** | 36 /** |
35 * The account to use in access checks. | 37 * The account to use in access checks. |
36 * | 38 * |
37 * @var \Drupal\Core\Session\AccountInterface; | 39 * @var \Drupal\Core\Session\AccountInterface |
38 */ | 40 */ |
39 protected $account; | 41 protected $account; |
40 | 42 |
41 /** | 43 /** |
42 * Constructs a router for Drupal with access check and upcasting. | 44 * Constructs a router for Drupal with access check and upcasting. |
109 // access result attribute is already set, don't overwrite it. | 111 // access result attribute is already set, don't overwrite it. |
110 if (!$request->attributes->has(AccessAwareRouterInterface::ACCESS_RESULT)) { | 112 if (!$request->attributes->has(AccessAwareRouterInterface::ACCESS_RESULT)) { |
111 $request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, $access_result); | 113 $request->attributes->set(AccessAwareRouterInterface::ACCESS_RESULT, $access_result); |
112 } | 114 } |
113 if (!$access_result->isAllowed()) { | 115 if (!$access_result->isAllowed()) { |
114 throw new AccessDeniedHttpException($access_result instanceof AccessResultReasonInterface ? $access_result->getReason() : NULL); | 116 if ($access_result instanceof CacheableDependencyInterface && $request->isMethodCacheable()) { |
117 throw new CacheableAccessDeniedHttpException($access_result, $access_result instanceof AccessResultReasonInterface ? $access_result->getReason() : NULL); | |
118 } | |
119 else { | |
120 throw new AccessDeniedHttpException($access_result instanceof AccessResultReasonInterface ? $access_result->getReason() : NULL); | |
121 } | |
115 } | 122 } |
116 } | 123 } |
117 | 124 |
118 /** | 125 /** |
119 * {@inheritdoc} | 126 * {@inheritdoc} |