Pull merge.
[yaffs-website] / web / core / modules / layout_builder / src / Access / LayoutBuilderAccessCheck.php
1 <?php
2
3 namespace Drupal\layout_builder\Access;
4
5 use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
6 use Drupal\Core\Routing\Access\AccessInterface;
7 use Drupal\Core\Session\AccountInterface;
8 use Drupal\layout_builder\SectionStorageInterface;
9 use Symfony\Component\Routing\Route;
10
11 /**
12  * Provides an access check for the Layout Builder defaults.
13  *
14  * @internal
15  */
16 class LayoutBuilderAccessCheck implements AccessInterface {
17
18   /**
19    * Checks routing access to the layout.
20    *
21    * @param \Drupal\layout_builder\SectionStorageInterface $section_storage
22    *   The section storage.
23    * @param \Drupal\Core\Session\AccountInterface $account
24    *   The current user.
25    * @param \Symfony\Component\Routing\Route $route
26    *   The route to check against.
27    *
28    * @return \Drupal\Core\Access\AccessResultInterface
29    *   The access result.
30    */
31   public function access(SectionStorageInterface $section_storage, AccountInterface $account, Route $route) {
32     $operation = $route->getRequirement('_layout_builder_access');
33     $access = $section_storage->access($operation, $account, TRUE);
34     if ($access instanceof RefinableCacheableDependencyInterface) {
35       $access->addCacheableDependency($section_storage);
36     }
37     return $access;
38   }
39
40 }