public PlaceholderGenerator::shouldAutomaticallyPlaceholder(array $element)
Whether the given render array should be automatically placeholdered.
The render array should be placeholdered if its cacheability either has a cache context with too high cardinality, a cache tag with a too high invalidation rate, or a max-age that is too low. Either of these would make caching ineffective, and thus we choose to placeholder instead.
Parameters
array $element: The render array whose cacheability to analyze.
Return value
bool Whether the given render array's cacheability meets the placeholdering conditions.
Overrides PlaceholderGeneratorInterface::shouldAutomaticallyPlaceholder
File
- core/lib/Drupal/Core/Render/PlaceholderGenerator.php, line 46
Class
- PlaceholderGenerator
- Turns a render array into a placeholder.
Namespace
Drupal\Core\Render
Code
public function shouldAutomaticallyPlaceholder(array $element) { // Auto-placeholder if the max-age, cache context or cache tag is specified // in the auto-placeholder conditions in the 'renderer.config' container // parameter. $conditions = $this->rendererConfig['auto_placeholder_conditions']; if (isset($element['#cache']['max-age']) && $element['#cache']['max-age'] !== Cache::PERMANENT && $element['#cache']['max-age'] <= $conditions['max-age']) { return TRUE; } if (isset($element['#cache']['contexts']) && array_intersect($element['#cache']['contexts'], $conditions['contexts'])) { return TRUE; } if (isset($element['#cache']['tags']) && array_intersect($element['#cache']['tags'], $conditions['tags'])) { return TRUE; } return FALSE; }
Please login to continue.