You are here

abstract class BaseRecursionController in Render cache 7.2

Base class for RecursionController plugin objects.

Used for render cache controllers that support recursion.

Hierarchy

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\Controller
View 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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractBaseController::render abstract protected function Render uncached objects. 3
BaseController::$cache protected property The injected cache backend adapter.
BaseController::$context protected property An optional context provided by this controller.
BaseController::$renderStack protected property The injected render stack.
BaseController::alter protected function Overrides AbstractBaseController::alter
BaseController::determineCachingStrategy protected function Determines the caching strategy for a given cache info structure.
BaseController::getCacheContext protected function Overrides AbstractBaseController::getCacheContext 2
BaseController::getCacheHash protected function Overrides AbstractBaseController::getCacheHash 3
BaseController::getCacheIdInfo protected function Provides the fully pouplated cache information for a specific object. Overrides AbstractBaseController::getCacheIdInfo
BaseController::getCacheInfo protected function Specific cache info overrides based on the $object. Overrides AbstractBaseController::getCacheInfo 1
BaseController::getCacheInfoMap protected function Returns the cache information map for the given objects.
BaseController::getCacheKeys protected function Overrides AbstractBaseController::getCacheKeys 3
BaseController::getCacheTags protected function Overrides AbstractBaseController::getCacheTags 3
BaseController::getCacheValidate protected function Overrides AbstractBaseController::getCacheValidate
BaseController::getContext public function Overrides ControllerInterface::getContext
BaseController::getDefaultCacheInfo protected function Provides the cache info for all objects based on the context. Overrides AbstractBaseController::getDefaultCacheInfo 2
BaseController::getPlaceholders protected function Get the placeholders from the cache information map.
BaseController::isCacheable protected function Overrides AbstractBaseController::isCacheable 3
BaseController::renderPlaceholders public static function Overrides ControllerInterface::renderPlaceholders
BaseController::setContext public function Overrides ControllerInterface::setContext
BaseController::view public function Overrides ControllerInterface::view 1
BaseController::viewPlaceholders public function Overrides ControllerInterface::viewPlaceholders
BaseController::__construct public function Constructs a controller plugin object.
BaseRecursionController::recursionStep public function Ensures that recursion storage is added to the right cached object. Overrides RecursionControllerInterface::recursionStep
BaseRecursionController::renderRecursive protected function Renders uncached objects in a recursion compatible way. Overrides BaseController::renderRecursive