Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 namespace Drupal\Core\Render;
|
Chris@0
|
4
|
Chris@0
|
5 /**
|
Chris@0
|
6 * Defines an interface for caching rendered render arrays.
|
Chris@0
|
7 *
|
Chris@0
|
8 * @internal
|
Chris@0
|
9 *
|
Chris@0
|
10 * @see sec_caching
|
Chris@0
|
11 * @see \Drupal\Core\Render\RendererInterface
|
Chris@0
|
12 */
|
Chris@0
|
13 interface RenderCacheInterface {
|
Chris@0
|
14
|
Chris@0
|
15 /**
|
Chris@0
|
16 * Gets a cacheable render array for a render array and its rendered output.
|
Chris@0
|
17 *
|
Chris@0
|
18 * Given a render array and its rendered output (HTML string), return an array
|
Chris@0
|
19 * data structure that allows the render array and its associated metadata to
|
Chris@0
|
20 * be cached reliably (and is serialization-safe).
|
Chris@0
|
21 *
|
Chris@0
|
22 * If Drupal needs additional rendering metadata to be cached at some point,
|
Chris@0
|
23 * consumers of this method will continue to work. Those who only cache
|
Chris@0
|
24 * certain parts of a render array will cease to work.
|
Chris@0
|
25 *
|
Chris@0
|
26 * @param array $elements
|
Chris@0
|
27 * A render array, on which \Drupal\Core\Render\RendererInterface::render()
|
Chris@0
|
28 * has already been invoked.
|
Chris@0
|
29 *
|
Chris@0
|
30 * @return array
|
Chris@0
|
31 * An array representing the cacheable data for this render array.
|
Chris@0
|
32 */
|
Chris@0
|
33 public function getCacheableRenderArray(array $elements);
|
Chris@0
|
34
|
Chris@0
|
35 /**
|
Chris@0
|
36 * Gets the cached, pre-rendered element of a renderable element from cache.
|
Chris@0
|
37 *
|
Chris@0
|
38 * @param array $elements
|
Chris@0
|
39 * A renderable array.
|
Chris@0
|
40 *
|
Chris@0
|
41 * @return array|false
|
Chris@0
|
42 * A renderable array, with the original element and all its children pre-
|
Chris@0
|
43 * rendered, or FALSE if no cached copy of the element is available.
|
Chris@0
|
44 *
|
Chris@0
|
45 * @see \Drupal\Core\Render\RendererInterface::render()
|
Chris@0
|
46 * @see ::set()
|
Chris@0
|
47 */
|
Chris@0
|
48 public function get(array $elements);
|
Chris@0
|
49
|
Chris@0
|
50 /**
|
Chris@0
|
51 * Caches the rendered output of a renderable array.
|
Chris@0
|
52 *
|
Chris@0
|
53 * May be called by an implementation of \Drupal\Core\Render\RendererInterface
|
Chris@0
|
54 * while rendering, if the #cache property is set.
|
Chris@0
|
55 *
|
Chris@0
|
56 * @param array $elements
|
Chris@0
|
57 * A renderable array.
|
Chris@0
|
58 * @param array $pre_bubbling_elements
|
Chris@0
|
59 * A renderable array corresponding to the state (in particular, the
|
Chris@0
|
60 * cacheability metadata) of $elements prior to the beginning of its
|
Chris@0
|
61 * rendering process, and therefore before any bubbling of child
|
Chris@0
|
62 * information has taken place. Only the #cache property is used by this
|
Chris@0
|
63 * function, so the caller may omit all other properties and children from
|
Chris@0
|
64 * this array.
|
Chris@0
|
65 *
|
Chris@0
|
66 * @return bool|null
|
Chris@0
|
67 * Returns FALSE if no cache item could be created, NULL otherwise.
|
Chris@0
|
68 *
|
Chris@0
|
69 * @see ::get()
|
Chris@0
|
70 */
|
Chris@0
|
71 public function set(array &$elements, array $pre_bubbling_elements);
|
Chris@0
|
72
|
Chris@0
|
73 }
|