Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / views / tests / modules / views_test_data / src / Plugin / views / area / TestExample.php
1 <?php
2
3 namespace Drupal\views_test_data\Plugin\views\area;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Session\AccountInterface;
7 use Drupal\views\Plugin\views\area\AreaPluginBase;
8
9 /**
10  * Test area plugin.
11  *
12  * @see \Drupal\views\Tests\Handler\AreaTest
13  *
14  * @ViewsArea("test_example")
15  */
16 class TestExample extends AreaPluginBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   public function access(AccountInterface $account) {
22     return $this->options['custom_access'];
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function defineOptions() {
29     $options = parent::defineOptions();
30     $options['string'] = ['default' => ''];
31     $options['custom_access'] = ['default' => TRUE];
32
33     return $options;
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
40     parent::buildOptionsForm($form, $form_state);
41     $this->globalTokenForm($form, $form_state);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function render($empty = FALSE) {
48     if (!$empty || !empty($this->options['empty'])) {
49       return [
50         '#markup' => $this->globalTokenReplace($this->options['string']),
51       ];
52     }
53     return [];
54   }
55
56 }