3 namespace Drupal\views\Plugin\views\argument;
5 use Drupal\Core\Form\FormStateInterface;
8 * Argument handler that ignores the argument.
10 * @ingroup views_argument_handlers
12 * @ViewsArgument("null")
14 class NullArgument extends ArgumentPluginBase {
16 protected function defineOptions() {
17 $options = parent::defineOptions();
18 $options['must_not_be'] = ['default' => FALSE];
23 * Override buildOptionsForm() so that only the relevant options
24 * are displayed to the user.
26 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
27 parent::buildOptionsForm($form, $form_state);
28 $form['must_not_be'] = [
29 '#type' => 'checkbox',
30 '#title' => $this->t('Fail basic validation if any argument is given'),
31 '#default_value' => !empty($this->options['must_not_be']),
32 '#description' => $this->t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
33 '#group' => 'options][more',
36 unset($form['exception']);
40 * Override defaultActions() to remove actions that don't
41 * make sense for a null argument.
43 protected function defaultActions($which = NULL) {
45 if (in_array($which, ['ignore', 'not found', 'empty', 'default'])) {
46 return parent::defaultActions($which);
50 $actions = parent::defaultActions();
51 unset($actions['summary asc']);
52 unset($actions['summary desc']);
57 * Override the behavior of query() to prevent the query
58 * from being changed in any way.
60 public function query($group_by = FALSE) {}