You are here

function token_render_cache_set in Token 8

Same name and namespace in other branches
  1. 7 token.module \token_render_cache_set()

Coyp of drupal_render_cache_set() that does not care about request method.

File

./token.module, line 474
Enhances the token API in core: adds a browseable UI, missing tokens, etc.

Code

function token_render_cache_set(&$markup, $elements) {

  // This should only run of drupal_render_cache_set() did not.
  if (in_array(\Drupal::request()->server
    ->get('REQUEST_METHOD'), [
    'GET',
    'HEAD',
  ])) {
    return FALSE;
  }
  $original_method = \Drupal::request()->server
    ->get('REQUEST_METHOD');
  \Drupal::request()->server
    ->set('REQUEST_METHOD', 'GET');
  drupal_render_cache_set($markup, $elements);
  \Drupal::request()->server
    ->set('REQUEST_METHOD', $original_method);
}