protected function Renderer::replacePlaceholders

protected Renderer::replacePlaceholders(array &$elements)

Replaces placeholders.

Placeholders may have:

  • #lazy_builder callback, to build a render array to be rendered into markup that can replace the placeholder
  • #cache: to cache the result of the placeholder

Also merges the bubbleable metadata resulting from the rendering of the contents of the placeholders. Hence $elements will be contain the entirety of bubbleable metadata.

@returns bool Whether placeholders were replaced.

Parameters

array &$elements: The structured array describing the data being rendered. Including the bubbleable metadata associated with the markup that replaced the placeholders.

See also

\Drupal\Core\Render\Renderer::renderPlaceholder()

File

core/lib/Drupal/Core/Render/Renderer.php, line 634

Class

Renderer
Turns a render array into a HTML string.

Namespace

Drupal\Core\Render

Code

protected function replacePlaceholders(array &$elements) {
  if (!isset($elements['#attached']['placeholders']) || empty($elements['#attached']['placeholders'])) {
    return FALSE;
  }

  foreach (array_keys($elements['#attached']['placeholders']) as $placeholder) {
    $elements = $this->renderPlaceholder($placeholder, $elements);
  }

  return TRUE;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Renderer.php/function/Renderer::replacePlaceholders/8.1.x