You are here

public static function RenderCachePlaceholder::loadPlaceholderFunctionArgs in Render cache 7.2

Loads the %load arguments within $context['args'].

Parameters

array $context: An array with the following keys:

  • function: The function to call.
  • args: The arguments to process.

Return value

array The function arguments suitable for call_user_func_array() with an argument keyed %node with a value of nid replaced with the loaded $node.

Overrides RenderCachePlaceholderInterface::loadPlaceholderFunctionArgs

See also

RenderCachePlaceholderInterface::getPlaceholder()

2 calls to RenderCachePlaceholder::loadPlaceholderFunctionArgs()
RenderCachePlaceholder::postRenderCacheCallback in src/Cache/RenderCachePlaceholder.php
Generic #post_render_cache callback for getPlaceholder().
RenderCachePlaceholder::postRenderCacheMultiCallback in src/Cache/RenderCachePlaceholder.php
Generic #post_render_cache callback for getPlaceholder() with multi=TRUE.

File

src/Cache/RenderCachePlaceholder.php, line 106
Contains \Drupal\render_cache\Cache\RenderCachePlaceholder

Class

RenderCachePlaceholder
Provides placeholder utility functions.

Namespace

Drupal\render_cache\Cache

Code

public static function loadPlaceholderFunctionArgs(array $context) {
  $args = array();
  foreach ($context['args'] as $key => $arg) {

    // In case a dynamic argument has been passed, load it with the loader.
    if (strpos($key, '%') !== 0) {
      $args[$key] = $arg;
      continue;
    }
    $prefix = substr($key, 1);
    $loader_functions = array(
      $prefix . '_load',
      $prefix . 'Load',
    );
    foreach ($loader_functions as $loader_function) {
      if (is_callable($loader_function)) {
        $arg = call_user_func($loader_function, $arg);
      }
    }
    $args[$key] = $arg;
  }
  return $args;
}