abstract class RendererBase in Views Parity Row 8
Renders entities in the current language.
Hierarchy
- class \Drupal\views\Entity\Render\RendererBase implements CacheableDependencyInterface
- class \Drupal\views_parity_row\Plugin\views\Entity\Render\RendererBase
Expanded class hierarchy of RendererBase
File
- src/
Plugin/ views/ Entity/ Render/ RendererBase.php, line 12
Namespace
Drupal\views_parity_row\Plugin\views\Entity\RenderView source
abstract class RendererBase extends ViewsRendererBase {
/**
* {@inheritdoc}
*/
public function preRender(array $result) {
$view_builder = $this->view->rowPlugin
->getEntityTypeManager()
->getViewBuilder($this->entityType
->id());
$previous_pages_item_count = $this->view->pager
->getCurrentPage() * $this->view->pager
->getItemsPerPage();
$options = $this->view->rowPlugin->options;
/** @var \Drupal\views\ResultRow $row */
foreach ($result as $row) {
$entity = $row->_entity;
$view_mode = $options['view_mode'];
$current_item = $previous_pages_item_count + $row->index;
if ($options['views_parity_row_enable']) {
$view_mode_override = FALSE;
if ($current_item >= $options['views_parity_row']['start']) {
if ($options['views_parity_row']['end'] !== '0') {
if ($current_item < $options['views_parity_row']['end']) {
$view_mode_override = TRUE;
}
}
else {
$view_mode_override = TRUE;
}
}
if ($view_mode_override) {
if (($current_item - $options['views_parity_row']['start']) % $options['views_parity_row']['frequency'] === 0) {
$view_mode = $options['views_parity_row']['view_mode'];
}
}
}
if ($options['views_parity_row_per_row_enable'] && !empty($options['views_parity_row_per_row']['view_mode_' . ($current_item + 1)])) {
$view_mode = $options['views_parity_row_per_row']['view_mode_' . ($current_item + 1)];
}
$this->build[$entity
->id()] = $view_builder
->view($entity, $view_mode, $this
->getLangcode($row));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RendererBase:: |
protected | property | Contains an array of render arrays, one for each rendered entity. | |
RendererBase:: |
protected | property | The type of the entity being rendered. | |
RendererBase:: |
protected | property | The language manager. | |
RendererBase:: |
public | property | The view executable wrapping the view storage entity. | |
RendererBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
2 |
RendererBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyInterface:: |
|
RendererBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyInterface:: |
|
RendererBase:: |
public | function |
Runs before each entity is rendered. Overrides RendererBase:: |
|
RendererBase:: |
abstract public | function | Alters the query if needed. | 2 |
RendererBase:: |
abstract public | function | Renders entity data. | 2 |
RendererBase:: |
public | function | Constructs a renderer object. | 2 |