Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Plugin / views / access / StaticTest.php
1 <?php
2
3 namespace Drupal\views_test_data\Plugin\views\access;
4
5 use Drupal\Core\Session\AccountInterface;
6 use Drupal\views\Plugin\views\access\AccessPluginBase;
7 use Symfony\Component\Routing\Route;
8
9 /**
10  * Tests a static access plugin.
11  *
12  * @ViewsAccess(
13  *   id = "test_static",
14  *   title = @Translation("Static test access plugin"),
15  *   help = @Translation("Provides a static test access plugin.")
16  * )
17  */
18 class StaticTest extends AccessPluginBase {
19
20   protected function defineOptions() {
21     $options = parent::defineOptions();
22     $options['access'] = ['default' => FALSE];
23
24     return $options;
25   }
26
27   /**
28    * {@inheritdoc}
29    */
30   public function access(AccountInterface $account) {
31     return !empty($this->options['access']);
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function alterRouteDefinition(Route $route) {
38     if (!empty($this->options['access'])) {
39       $route->setRequirement('_access', 'TRUE');
40     }
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function calculateDependencies() {
47     return [
48       'content' => ['StaticTest'],
49     ];
50   }
51
52 }