Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / views / src / ExposedFormCache.php
1 <?php
2
3 namespace Drupal\views;
4
5 /**
6  * Caches exposed forms, as they are heavy to generate.
7  *
8  * @see \Drupal\views\Form\ViewsExposedForm
9  */
10 class ExposedFormCache {
11
12   /**
13    * Stores the exposed form data.
14    *
15    * @var array
16    */
17   protected $cache = [];
18
19   /**
20    * Save the Views exposed form for later use.
21    *
22    * @param string $view_id
23    *   The views ID.
24    * @param string $display_id
25    *   The current view display name.
26    * @param array $form_output
27    *   The form structure. Only needed when inserting the value.
28    */
29   public function setForm($view_id, $display_id, array $form_output) {
30     // Save the form output.
31     $views_exposed[$view_id][$display_id] = $form_output;
32   }
33
34   /**
35    * Retrieves the views exposed form from cache.
36    *
37    * @param string $view_id
38    *   The views ID.
39    * @param string $display_id
40    *   The current view display name.
41    *
42    * @return array|bool
43    *   The form structure, if any, otherwise FALSE.
44    */
45   public function getForm($view_id, $display_id) {
46     // Return the form output, if any.
47     if (empty($this->cache[$view_id][$display_id])) {
48       return FALSE;
49     }
50     else {
51       return $this->cache[$view_id][$display_id];
52     }
53   }
54
55   /**
56    * Rests the form cache.
57    */
58   public function reset() {
59     $this->cache = [];
60   }
61
62 }