You are here

public static function BaseController::renderPlaceholders in Render cache 7.2

Parameters

array $args:

Return value

array|string

Overrides ControllerInterface::renderPlaceholders

File

src/RenderCache/Controller/BaseController.php, line 530
Contains \Drupal\render_cache\RenderCache\Controller\BaseController

Class

BaseController
Base class for Controller plugin objects.

Namespace

Drupal\render_cache\RenderCache\Controller

Code

public static function renderPlaceholders(array $args) {
  $all_placeholders = array();
  $strategies = array();
  foreach ($args as $placeholder => $ph_object) {
    foreach ($ph_object['render_strategy'] as $render_strategy) {
      $strategies[$render_strategy][$placeholder] = $placeholder;
    }

    // Fallback to direct rendering.
    $strategies['direct'][$placeholder] = $placeholder;
  }
  foreach ($strategies as $render_strategy => $placeholder_keys) {
    $rcs = render_cache_get_renderer($render_strategy);
    if (!$rcs) {
      continue;
    }
    $objects = array_intersect_key($args, $placeholder_keys);
    if (empty($objects)) {
      continue;
    }
    $placeholders = $rcs
      ->render($objects);
    foreach ($placeholders as $placeholder => $render) {
      $all_placeholders[$placeholder] = $render;
      unset($args[$placeholder]);
    }
  }
  return $all_placeholders;
}