Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityTranslationRendererBase.php

function EntityTranslationRendererBase::getEntity

Gets the entity associated with a row.

Parameters

\Drupal\views\ResultRow $row: The result row.

string $relationship: (optional) The relationship.

Return value

\Drupal\Core\Entity\EntityInterface|null The entity might be optional, because the relationship entity might not always exist.

5 calls to EntityTranslationRendererBase::getEntity()
DefaultLanguageRenderer::getLangcodeByRelationship in core/modules/views/src/Entity/Render/DefaultLanguageRenderer.php
Returns the language code associated with the given row.
EntityTranslationRendererBase::preRenderByRelationship in core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
Runs before each entity is rendered if a relationship is needed.
EntityTranslationRendererBase::renderByRelationship in core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php
Renders entity data.
TranslationLanguageRenderer::preRenderByRelationship in core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
Runs before each entity is rendered if a relationship is needed.
TranslationLanguageRenderer::renderByRelationship in core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php
Renders entity data.

File

core/modules/views/src/Entity/Render/EntityTranslationRendererBase.php, line 111

Class

EntityTranslationRendererBase
Defines a base class for entity translation renderers.

Namespace

Drupal\views\Entity\Render

Code

protected function getEntity(ResultRow $row, string $relationship = 'none') : ?EntityInterface {
    if ($relationship === 'none') {
        return $row->_entity;
    }
    elseif (isset($row->_relationship_entities[$relationship])) {
        return $row->_relationship_entities[$relationship];
    }
    return NULL;
}
RSS feed
Powered by Drupal