You are here

function CachePluginBase::gather_headers in Views (for Drupal 7) 8.3

Gather out of band data, compare it to what we started with and store the difference.

1 call to CachePluginBase::gather_headers()
CachePluginBase::cache_set in lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
Save data to the cache.

File

lib/Drupal/views/Plugin/views/cache/CachePluginBase.php, line 240
Definition of Drupal\views\Plugin\views\cache\CachePluginBase.

Class

CachePluginBase
The base plugin to handle caching.

Namespace

Drupal\views\Plugin\views\cache

Code

function gather_headers() {

  // Simple replacement for head
  if (isset($this->storage['head'])) {
    $this->storage['head'] = str_replace($this->storage['head'], '', drupal_add_html_head());
  }
  else {
    $this->storage['head'] = '';
  }

  // Slightly less simple for CSS:
  $css = drupal_add_css();
  $css_start = isset($this->storage['css']) ? $this->storage['css'] : array();
  $this->storage['css'] = array_diff_assoc($css, $css_start);

  // Get javascript after/before views renders.
  $js = drupal_add_js();
  $js_start = isset($this->storage['js']) ? $this->storage['js'] : array();

  // If there are any differences between the old and the new javascript then
  // store them to be added later.
  $this->storage['js'] = array_diff_assoc($js, $js_start);

  // Special case the settings key and get the difference of the data.
  $settings = isset($js['settings']['data']) ? $js['settings']['data'] : array();
  $settings_start = isset($js_start['settings']['data']) ? $js_start['settings']['data'] : array();
  $this->storage['js']['settings'] = array_diff_assoc($settings, $settings_start);
}