Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/layout_builder/src/Access/LayoutBuilderAccessCheck.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\layout_builder\Access; | 3 namespace Drupal\layout_builder\Access; |
4 | 4 |
5 use Drupal\Core\Access\AccessResult; | |
5 use Drupal\Core\Cache\RefinableCacheableDependencyInterface; | 6 use Drupal\Core\Cache\RefinableCacheableDependencyInterface; |
6 use Drupal\Core\Routing\Access\AccessInterface; | 7 use Drupal\Core\Routing\Access\AccessInterface; |
7 use Drupal\Core\Session\AccountInterface; | 8 use Drupal\Core\Session\AccountInterface; |
8 use Drupal\layout_builder\SectionStorageInterface; | 9 use Drupal\layout_builder\SectionStorageInterface; |
9 use Symfony\Component\Routing\Route; | 10 use Symfony\Component\Routing\Route; |
10 | 11 |
11 /** | 12 /** |
12 * Provides an access check for the Layout Builder defaults. | 13 * Provides an access check for the Layout Builder defaults. |
13 * | 14 * |
15 * @ingroup layout_builder_access | |
16 * | |
14 * @internal | 17 * @internal |
18 * Tagged services are internal. | |
15 */ | 19 */ |
16 class LayoutBuilderAccessCheck implements AccessInterface { | 20 class LayoutBuilderAccessCheck implements AccessInterface { |
17 | 21 |
18 /** | 22 /** |
19 * Checks routing access to the layout. | 23 * Checks routing access to the layout. |
29 * The access result. | 33 * The access result. |
30 */ | 34 */ |
31 public function access(SectionStorageInterface $section_storage, AccountInterface $account, Route $route) { | 35 public function access(SectionStorageInterface $section_storage, AccountInterface $account, Route $route) { |
32 $operation = $route->getRequirement('_layout_builder_access'); | 36 $operation = $route->getRequirement('_layout_builder_access'); |
33 $access = $section_storage->access($operation, $account, TRUE); | 37 $access = $section_storage->access($operation, $account, TRUE); |
38 | |
39 // Check for the global permission unless the section storage checks | |
40 // permissions itself. | |
41 if (!$section_storage->getPluginDefinition()->get('handles_permission_check')) { | |
42 $access = $access->andIf(AccessResult::allowedIfHasPermission($account, 'configure any layout')); | |
43 } | |
44 | |
34 if ($access instanceof RefinableCacheableDependencyInterface) { | 45 if ($access instanceof RefinableCacheableDependencyInterface) { |
35 $access->addCacheableDependency($section_storage); | 46 $access->addCacheableDependency($section_storage); |
36 } | 47 } |
37 return $access; | 48 return $access; |
38 } | 49 } |