Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / views / src / Plugin / views / argument_default / ArgumentDefaultPluginBase.php
1 <?php
2
3 namespace Drupal\views\Plugin\views\argument_default;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
7 use Drupal\views\Plugin\views\PluginBase;
8
9 /**
10  * @defgroup views_argument_default_plugins Views argument default plugins
11  * @{
12  * Plugins for argument defaults in Views.
13  *
14  * Argument default plugins provide default values for contextual filters. This
15  * can be useful for blocks and other display types lacking a natural argument
16  * input. Examples are plugins to extract node and user IDs from the URL.
17  *
18  * Argument default plugins extend
19  * \Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase. They
20  * must be annotated with \Drupal\views\Annotation\ViewsArgumentDefault
21  * annotation, and they must be in namespace directory
22  * Plugin\views\argument_default.
23  *
24  * @ingroup views_plugins
25  * @see plugin_api
26  */
27
28 /**
29  * The fixed argument default handler; also used as the base.
30  */
31 abstract class ArgumentDefaultPluginBase extends PluginBase {
32
33   /**
34    * The argument handler instance associated with this plugin.
35    *
36    * @var \Drupal\views\Plugin\views\argument\ArgumentPluginBase
37    */
38   protected $argument;
39
40   /**
41    * Return the default argument.
42    *
43    * This needs to be overridden by every default argument handler to properly do what is needed.
44    */
45   public function getArgument() {}
46
47   /**
48    * Sets the parent argument this plugin is associated with.
49    *
50    * @param \Drupal\views\Plugin\views\argument\ArgumentPluginBase $argument
51    *   The parent argument to set.
52    */
53   public function setArgument(ArgumentPluginBase $argument) {
54     $this->argument = $argument;
55   }
56
57   /**
58    * Retrieve the options when this is a new access
59    * control plugin
60    */
61   protected function defineOptions() {
62     return [];
63   }
64
65   /**
66    * Provide the default form for setting options.
67    */
68   public function buildOptionsForm(&$form, FormStateInterface $form_state) {}
69
70   /**
71    * Provide the default form form for validating options
72    */
73   public function validateOptionsForm(&$form, FormStateInterface $form_state) {}
74
75   /**
76    * Provide the default form form for submitting options
77    */
78   public function submitOptionsForm(&$form, FormStateInterface $form_state, &$options = []) {}
79
80   /**
81    * Determine if the administrator has the privileges to use this
82    * plugin
83    */
84   public function access() {
85     return TRUE;
86   }
87
88   /**
89    * If we don't have access to the form but are showing it anyway, ensure that
90    * the form is safe and cannot be changed from user input.
91    *
92    * This is only called by child objects if specified in the buildOptionsForm(),
93    * so it will not always be used.
94    */
95   protected function checkAccess(&$form, $option_name) {
96     if (!$this->access()) {
97       $form[$option_name]['#disabled'] = TRUE;
98       $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
99       $form[$option_name]['#description'] .= ' <strong>' . $this->t('Note: you do not have permission to modify this. If you change the default filter type, this setting will be lost and you will NOT be able to get it back.') . '</strong>';
100     }
101   }
102
103   /**
104    * {@inheritdoc}
105    */
106   public function getCacheTags() {
107     return [];
108   }
109
110 }
111
112 /**
113  * @}
114  */