class RendererBase
Same name in other branches
- 9 core/modules/views/src/Entity/Render/RendererBase.php \Drupal\views\Entity\Render\RendererBase
- 8.9.x core/modules/views/src/Entity/Render/RendererBase.php \Drupal\views\Entity\Render\RendererBase
- 11.x core/modules/views/src/Entity/Render/RendererBase.php \Drupal\views\Entity\Render\RendererBase
Defines a base class for entity renderers.
Hierarchy
- class \Drupal\views\Entity\Render\RendererBase implements \Drupal\Core\Cache\CacheableDependencyInterface
Expanded class hierarchy of RendererBase
File
-
core/
modules/ views/ src/ Entity/ Render/ RendererBase.php, line 16
Namespace
Drupal\views\Entity\RenderView source
abstract class RendererBase implements CacheableDependencyInterface {
/**
* The view executable wrapping the view storage entity.
*
* @var \Drupal\views\ViewExecutable
*/
public $view;
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* The type of the entity being rendered.
*
* @var \Drupal\Core\Entity\EntityTypeInterface
*/
protected $entityType;
/**
* Contains an array of render arrays, one for each rendered entity.
*
* @var array
*/
protected $build;
/**
* Constructs a renderer object.
*
* @param \Drupal\views\ViewExecutable $view
* The entity row being rendered.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*/
public function __construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type) {
$this->view = $view;
$this->languageManager = $language_manager;
$this->entityType = $entity_type;
}
/**
* {@inheritdoc}
*/
public function getCacheMaxAge() {
return Cache::PERMANENT;
}
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
return [];
}
/**
* {@inheritdoc}
*/
public function getCacheTags() {
return [];
}
/**
* Alters the query if needed.
*
* @param \Drupal\views\Plugin\views\query\QueryPluginBase $query
* The query to alter.
* @param string $relationship
* (optional) The relationship, used by a field.
*/
public abstract function query(QueryPluginBase $query, $relationship = NULL);
/**
* Runs before each entity is rendered.
*
* @param \Drupal\views\ResultRow[] $result
* The full array of results from the query.
*/
public function preRender(array $result) {
}
/**
* Renders entity data.
*
* @param \Drupal\views\ResultRow $row
* A single row of the query result.
*
* @return array
* A renderable array for the entity data contained in the result row.
*/
public abstract function render(ResultRow $row);
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
RendererBase::$build | protected | property | Contains an array of render arrays, one for each rendered entity. | ||
RendererBase::$entityType | protected | property | The type of the entity being rendered. | ||
RendererBase::$languageManager | protected | property | The language manager. | ||
RendererBase::$view | public | property | The view executable wrapping the view storage entity. | ||
RendererBase::getCacheContexts | public | function | The cache contexts associated with this object. | Overrides CacheableDependencyInterface::getCacheContexts | 2 |
RendererBase::getCacheMaxAge | public | function | The maximum age for which this object may be cached. | Overrides CacheableDependencyInterface::getCacheMaxAge | |
RendererBase::getCacheTags | public | function | The cache tags associated with this object. | Overrides CacheableDependencyInterface::getCacheTags | |
RendererBase::preRender | public | function | Runs before each entity is rendered. | 1 | |
RendererBase::query | abstract public | function | Alters the query if needed. | 2 | |
RendererBase::render | abstract public | function | Renders entity data. | 2 | |
RendererBase::__construct | public | function | Constructs a renderer object. | 2 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.