abstract class BaseRecursionController in Render cache 7.2
Base class for RecursionController plugin objects.
Used for render cache controllers that support recursion.
Hierarchy
- class \Drupal\render_cache\RenderCache\Controller\AbstractBaseController extends \Drupal\Component\Plugin\PluginBase implements ControllerInterface
- class \Drupal\render_cache\RenderCache\Controller\BaseController
- class \Drupal\render_cache\RenderCache\Controller\BaseRecursionController implements RecursionControllerInterface
- class \Drupal\render_cache\RenderCache\Controller\BaseController
Expanded class hierarchy of BaseRecursionController
2 files declare their use of BaseRecursionController
- BlockController.php in modules/
controller/ render_cache_block/ src/ RenderCache/ Controller/ BlockController.php - Contains \Drupal\render_cache_block\RenderCache\Controller\BlockController
- EntityController.php in modules/
controller/ render_cache_entity/ src/ RenderCache/ Controller/ EntityController.php - Contains \Drupal\render_cache_entity\RenderCache\Controller\EntityController
File
- src/
RenderCache/ Controller/ BaseRecursionController.php, line 16 - Contains \Drupal\render_cache\RenderCache\Controller\BaseRecursionController
Namespace
Drupal\render_cache\RenderCache\ControllerView source
abstract class BaseRecursionController extends BaseController implements RecursionControllerInterface {
/**
* {@inheritdoc}
*/
public function recursionStep(array &$build) {
$storage = $this->renderStack
->decreaseRecursion();
if (!empty($build)) {
$build['x_render_cache_recursion_storage'] = $storage;
}
$this->renderStack
->increaseRecursion();
}
/**
* {@inheritdoc}
*/
protected function renderRecursive(array $objects) {
// This provides an optimized version for rendering in a
// recursive way.
//
// @see BaseController::renderRecursive()
// Store the render cache controller within the objects.
foreach ($objects as $object) {
if (is_object($object)) {
$object->render_cache_controller = $this;
}
}
// Increase recursion for the first step.
$this->renderStack
->increaseRecursion();
// Now build the objects, the implementing class
// is responsible to call recursionStep()
// after each object has been individually built.
$build = $this
->render($objects);
// Decrease recursion as the last step.
$this->renderStack
->decreaseRecursion();
// Remove the render cache controller within the objects again.
foreach ($objects as $object) {
if (is_object($object)) {
unset($object->render_cache_controller);
}
}
return $build;
}
}