Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / service / access-checker.twig
1 <?php
2
3 namespace Drupal\{{ machine_name }}\Access;
4
5 use Drupal\Core\Access\AccessResult;
6 use Drupal\Core\Routing\Access\AccessInterface;
7 use Symfony\Component\Routing\Route;
8
9 /**
10  * Checks if passed parameter matches the route configuration.
11  *
12  * @DCG
13  * To make use of this access checker add '{{ applies_to }}: Some value' entry to route
14  * definition under requirements section.
15  */
16 class {{ class }} implements AccessInterface {
17
18   /**
19    * Access callback.
20    *
21    * @param \Symfony\Component\Routing\Route $route
22    *   The route to check against.
23    * @param \ExampleInterface $parameter
24    *   The parameter to test.
25    *
26    * @return \Drupal\Core\Access\AccessResultInterface
27    *   The access result.
28    */
29   public function access(Route $route, \ExampleInterface $parameter) {
30     return AccessResult::allowedIf($parameter->getSomeValue() == $route->getRequirement('{{ applies_to }}'));
31   }
32
33 }