3 namespace Drupal\Core\Render;
6 * Defines an interface for caching rendered render arrays.
11 * @see \Drupal\Core\Render\RendererInterface
13 interface RenderCacheInterface {
16 * Gets a cacheable render array for a render array and its rendered output.
18 * Given a render array and its rendered output (HTML string), return an array
19 * data structure that allows the render array and its associated metadata to
20 * be cached reliably (and is serialization-safe).
22 * If Drupal needs additional rendering metadata to be cached at some point,
23 * consumers of this method will continue to work. Those who only cache
24 * certain parts of a render array will cease to work.
26 * @param array $elements
27 * A render array, on which \Drupal\Core\Render\RendererInterface::render()
28 * has already been invoked.
31 * An array representing the cacheable data for this render array.
33 public function getCacheableRenderArray(array $elements);
36 * Gets the cached, pre-rendered element of a renderable element from cache.
38 * @param array $elements
42 * A renderable array, with the original element and all its children pre-
43 * rendered, or FALSE if no cached copy of the element is available.
45 * @see \Drupal\Core\Render\RendererInterface::render()
48 public function get(array $elements);
51 * Caches the rendered output of a renderable array.
53 * May be called by an implementation of \Drupal\Core\Render\RendererInterface
54 * while rendering, if the #cache property is set.
56 * @param array $elements
58 * @param array $pre_bubbling_elements
59 * A renderable array corresponding to the state (in particular, the
60 * cacheability metadata) of $elements prior to the beginning of its
61 * rendering process, and therefore before any bubbling of child
62 * information has taken place. Only the #cache property is used by this
63 * function, so the caller may omit all other properties and children from
67 * Returns FALSE if no cache item could be created, NULL otherwise.
71 public function set(array &$elements, array $pre_bubbling_elements);