Mercurial > hg > isophonics-drupal-site
comparison core/modules/layout_builder/src/Access/LayoutSectionAccessCheck.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\layout_builder\Access; | |
4 | |
5 use Drupal\Core\Access\AccessResult; | |
6 use Drupal\Core\Routing\Access\AccessInterface; | |
7 use Drupal\Core\Routing\RouteMatchInterface; | |
8 use Drupal\Core\Session\AccountInterface; | |
9 use Drupal\layout_builder\SectionStorageInterface; | |
10 | |
11 /** | |
12 * Provides an access check for the Layout Builder UI. | |
13 * | |
14 * @internal | |
15 */ | |
16 class LayoutSectionAccessCheck implements AccessInterface { | |
17 | |
18 /** | |
19 * Checks routing access to the layout. | |
20 * | |
21 * @param \Drupal\Core\Routing\RouteMatchInterface $route_match | |
22 * The current route match. | |
23 * @param \Drupal\Core\Session\AccountInterface $account | |
24 * The currently logged in account. | |
25 * | |
26 * @return \Drupal\Core\Access\AccessResultInterface | |
27 * The access result. | |
28 */ | |
29 public function access(RouteMatchInterface $route_match, AccountInterface $account) { | |
30 $section_storage = $route_match->getParameter('section_storage'); | |
31 | |
32 if (empty($section_storage)) { | |
33 return AccessResult::forbidden()->addCacheContexts(['route']); | |
34 } | |
35 | |
36 if (!$section_storage instanceof SectionStorageInterface) { | |
37 $access = AccessResult::forbidden(); | |
38 } | |
39 else { | |
40 $access = AccessResult::allowedIfHasPermission($account, 'configure any layout'); | |
41 } | |
42 | |
43 return $access->addCacheableDependency($section_storage); | |
44 } | |
45 | |
46 } |