You are here

public static function RenderCachePlaceholderInterface::getPlaceholder in Render cache 7.2

Gets a #post_render_cache placeholder for a given function.

Parameters

$function: The function to call when the #post_render_cache callback is invoked.

array $args: The arguments to pass to the function. This can contain %load arguments, similar to how menu paths are working.

$args = array(
  '%node' => $node->nid,
  'full',
);

Given %node the function node_load() will be called with the argument, the resulting function will just be given the $node as argument.

This can be any valid callable, so also %MyClass::staticMethod, where MyClass::staticMethodLoad() is called.

bool $multiple: Whether the function accepts multiple contexts. This is useful to group similar objects together.

Return value

array A render array with #markup set to the placeholder and #post_render_cache callback set to callback postRenderCacheCallback() with the given arguments and function encoded in the context.

1 method overrides RenderCachePlaceholderInterface::getPlaceholder()
RenderCachePlaceholder::getPlaceholder in src/Cache/RenderCachePlaceholder.php
Gets a #post_render_cache placeholder for a given function.

File

src/Cache/RenderCachePlaceholderInterface.php, line 44
Contains \Drupal\render_cache\Cache\RenderCachePlaceholderInterface

Class

RenderCachePlaceholderInterface
Defines an interface for #post_render_cache placeholders.

Namespace

Drupal\render_cache\Cache

Code

public static function getPlaceholder($function, array $args = array(), $multiple = FALSE);