You are here

public function RenderStackTest::helperCollectAttached in Render cache 7.2

Helper function to mock collect attached.

Parameters

array $render: The render array to process.

Return value

array The collected attachments.

File

tests/src/Cache/RenderStackTest.php, line 841
Contains \Drupal\render_cache\Tests\Cache\RenderStackTest

Class

RenderStackTest
@coversDefaultClass \Drupal\render_cache\Cache\RenderStack @group cache

Namespace

Drupal\render_cache\Tests\Cache

Code

public function helperCollectAttached(array $render) {
  if (!empty($render[2]['#attached']) && empty($render[1]['#attached'])) {
    return NestedArray::mergeDeep($render[0]['#attached'], $render[2]['#attached']);
  }
  if (!empty($render[2]['#attached'])) {
    return NestedArray::mergeDeep($render[0]['#attached'], $render[1]['#attached'], $render[2]['#attached']);
  }
  if (!empty($render[1]['#attached']) && !empty($render[0]['#attached'])) {
    return NestedArray::mergeDeep($render[0]['#attached'], $render[1]['#attached']);
  }
  if (!empty($render[1]['#attached'])) {
    return $render[1]['#attached'];
  }
  if (!empty($render[0]['#attached'])) {
    return $render[0]['#attached'];
  }
  if (!empty($render['#attached'])) {
    return $render['#attached'];
  }
  return array();
}