You are here

public function RenderStack::render in Render cache 7.2

File

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

Class

RenderStack
Defines the RenderStack service.

Namespace

Drupal\render_cache\Cache

Code

public function render(array &$render) {
  $this
    ->increaseRecursion();

  // Push our recursive stored storage on the stack first.
  if (!empty($render['x_render_cache_recursion_storage'])) {
    $storage = $render['x_render_cache_recursion_storage'];
    unset($render['x_render_cache_recursion_storage']);
    $this
      ->addRecursionStorage($storage, TRUE);
  }
  $markup = $this
    ->drupalRender($render);

  // In case the dynamic assets have not been processed via our
  // drupal_process_attached, we need to collect them ourselves.
  if (!$this
    ->supportsDynamicAssets()) {
    $storage = array();
    $storage['#attached'] = $this
      ->collectAttached($render);
    $this
      ->addRecursionStorage($storage, TRUE);
  }
  $storage = $this
    ->decreaseRecursion();
  $original_render = $render;
  $render = $storage;
  $render['#markup'] =& $markup;
  return array(
    $markup,
    $original_render,
  );
}