AbstractBaseController.php in Render cache 7.2
File
src/RenderCache/Controller/AbstractBaseController.phpView source
<?php
/**
* @file
* Contains \Drupal\render_cache\RenderCache\Controller\AbstractBaseController
*/
namespace Drupal\render_cache\RenderCache\Controller;
use Drupal\Component\Plugin\PluginBase;
/**
* Controller abstract base class.
*
* @ingroup rendercache
*/
abstract class AbstractBaseController extends PluginBase implements ControllerInterface {
// -----------------------------------------------------------------------
// Suggested implementation functions.
/**
* @param array $default_cache_info
* @param array $context
*
* @return bool
*/
protected abstract function isCacheable(array $default_cache_info, array $context);
/**
* Provides the cache info for all objects based on the context.
*
* @param array $context
*
* @return array
*/
protected abstract function getDefaultCacheInfo($context);
/**
* @param object $object
* @param array $context
*
* @return array
*/
protected abstract function getCacheContext($object, array $context);
/**
* Specific cache info overrides based on the $object.
*
* @param object $object
* @param array $context
*
* @return array
*/
protected abstract function getCacheInfo($object, array $context);
/**
* @param object $object
* @param array $context
*
* @return array
*/
protected abstract function getCacheKeys($object, array $context);
/**
* @param object $object
* @param array $context
*
* @return array
*/
protected abstract function getCacheHash($object, array $context);
/**
* @param object $object
* @param array $context
*
* @return array
*/
protected abstract function getCacheTags($object, array $context);
/**
* @param object $object
* @param array $context
*
* @return array
*/
protected abstract function getCacheValidate($object, array $context);
/**
* Render uncached objects.
*
* This function needs to be implemented by every child class.
*
* @param array $objects
* Array of $objects to be rendered keyed by id.
*
* @return array
* Render array keyed by id.
*/
protected abstract function render(array $objects);
/**
* Renders uncached objects in a recursion compatible way.
*
* The default implementation is dumb and expensive performance wise, as
* it calls the render() method for each object seperately.
*
* Controllers that support recursions should implement the
* RecursionControllerInterface and subclass from
* BaseRecursionController.
*
* @see \Drupal\render_cache\RenderCache\Controller\RecursionControllerInterface
* @see \Drupal\render_cache\RenderCache\Controller\BaseRecursionController
*
* @param object[] $objects
* Array of $objects to be rendered keyed by id.
*
* @return array[]
* Render array keyed by id.
*/
protected abstract function renderRecursive(array $objects);
// -----------------------------------------------------------------------
// Helper functions.
/**
* Provides the fully pouplated cache information for a specific object.
*
* @param object $object
* @param array $cache_info
* @param array $context
*
* @return array
*/
protected abstract function getCacheIdInfo($object, array $cache_info = array(), array $context = array());
/**
* @param string $type
* @param array $data
* @param mixed|null $context1
* @param mixed|null $context2
* @param mixed|null $context3
*/
protected abstract function alter($type, &$data, &$context1 = NULL, &$context2 = NULL, &$context3 = NULL);
}
Classes
Name | Description |
---|---|
AbstractBaseController | Controller abstract base class. |