Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / taxonomy / src / Plugin / views / argument / IndexTidDepthModifier.php
1 <?php
2
3 namespace Drupal\taxonomy\Plugin\views\argument;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
7
8 /**
9  * Argument handler for to modify depth for a previous term.
10  *
11  * This handler is actually part of the node table and has some restrictions,
12  * because it uses a subquery to find nodes with.
13  *
14  * @ingroup views_argument_handlers
15  *
16  * @ViewsArgument("taxonomy_index_tid_depth_modifier")
17  */
18 class IndexTidDepthModifier extends ArgumentPluginBase {
19
20   public function buildOptionsForm(&$form, FormStateInterface $form_state) {}
21
22   public function query($group_by = FALSE) {}
23
24   public function preQuery() {
25     // We don't know our argument yet, but it's based upon our position:
26     $argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL;
27     if (!is_numeric($argument)) {
28       return;
29     }
30
31     if ($argument > 10) {
32       $argument = 10;
33     }
34
35     if ($argument < -10) {
36       $argument = -10;
37     }
38
39     // figure out which argument preceded us.
40     $keys = array_reverse(array_keys($this->view->argument));
41     $skip = TRUE;
42     foreach ($keys as $key) {
43       if ($key == $this->options['id']) {
44         $skip = FALSE;
45         continue;
46       }
47
48       if ($skip) {
49         continue;
50       }
51
52       if (empty($this->view->argument[$key])) {
53         continue;
54       }
55
56       if (isset($handler)) {
57         unset($handler);
58       }
59
60       $handler = &$this->view->argument[$key];
61       if (empty($handler->definition['accept depth modifier'])) {
62         continue;
63       }
64
65       // Finally!
66       $handler->options['depth'] = $argument;
67     }
68   }
69
70 }