abstract class RendererBase implements CacheableDependencyInterface (View source)

Defines a base class for entity renderers.

Properties

ViewExecutable $view

The view executable wrapping the view storage entity.

protected LanguageManagerInterface $languageManager

The language manager.

protected EntityTypeInterface $entityType

The type of the entity being rendered.

protected array $build

Contains an array of render arrays, one for each rendered entity.

Methods

__construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type)

Constructs a renderer object.

int
getCacheMaxAge()

The maximum age for which this object may be cached.

string[]
getCacheContexts()

The cache contexts associated with this object.

string[]
getCacheTags()

The cache tags associated with this object.

query(QueryPluginBase $query, string $relationship = NULL)

Alters the query if needed.

preRender(array $result)

Runs before each entity is rendered.

array
render(ResultRow $row)

Renders entity data.

Details

__construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type)

Constructs a renderer object.

Parameters

ViewExecutable $view

The entity row being rendered.

LanguageManagerInterface $language_manager

The language manager.

EntityTypeInterface $entity_type

The entity type.

int getCacheMaxAge()

The maximum age for which this object may be cached.

Return Value

int

The maximum time in seconds that this object may be cached.

string[] getCacheContexts()

The cache contexts associated with this object.

These identify a specific variation/representation of the object.

Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.

Return Value

string[]

An array of cache context tokens, used to generate a cache ID.

string[] getCacheTags()

The cache tags associated with this object.

When this object is modified, these cache tags will be invalidated.

Return Value

string[]

A set of cache tags.

abstract query(QueryPluginBase $query, string $relationship = NULL)

Alters the query if needed.

Parameters

QueryPluginBase $query

The query to alter.

string $relationship

(optional) The relationship, used by a field.

preRender(array $result)

Runs before each entity is rendered.

Parameters

array $result

The full array of results from the query.

abstract array render(ResultRow $row)

Renders entity data.

Parameters

ResultRow $row

A single row of the query result.

Return Value

array

A renderable array for the entity data contained in the result row.