You are here

public function RenderStack::collectAndRemoveD8Properties in Render cache 7.2

2 calls to RenderStack::collectAndRemoveD8Properties()
RenderStack::collectAndRemoveAssets in src/Cache/RenderStack.php
RenderStack::convertRenderArrayToD7 in src/Cache/RenderStack.php
Converts a render array to be compatible with Drupal 7.

File

src/Cache/RenderStack.php, line 286
Contains \Drupal\render_cache\Cache\RenderStack

Class

RenderStack
Defines the RenderStack service.

Namespace

Drupal\render_cache\Cache

Code

public function collectAndRemoveD8Properties(&$element) {
  $render = array();
  if (!empty($element['#cache']['tags'])) {
    $render['#cache']['tags'] = $element['#cache']['tags'];
    unset($element['#cache']['tags']);
  }
  if (!empty($element['#cache']['max-age'])) {
    $render['#cache']['max-age'] = $element['#cache']['max-age'];
    unset($element['#cache']['max-age']);
  }
  if (!empty($element['#cache']['downstream-ttl'])) {
    $render['#cache']['downstream-ttl'] = $element['#cache']['downstream-ttl'];
    unset($element['#cache']['downstream-ttl']);
  }

  // Ensure the cache property is empty.
  if (empty($element['#cache'])) {
    unset($element['#cache']);
  }
  if (!empty($element['#post_render_cache'])) {
    $render['#post_render_cache'] = $element['#post_render_cache'];
    unset($element['#post_render_cache']);
  }
  return $render;
}