You are here

class ConfigurableLanguageRenderer in Views Parity Row 8

Renders entities in a configured language.

Hierarchy

Expanded class hierarchy of ConfigurableLanguageRenderer

1 string reference to 'ConfigurableLanguageRenderer'
EntityRow::getEntityTranslationRenderer in src/Plugin/views/row/EntityRow.php
Returns the current renderer.

File

src/Plugin/views/Entity/Render/ConfigurableLanguageRenderer.php, line 16

Namespace

Drupal\views_parity_row\Plugin\views\Entity\Render
View source
class ConfigurableLanguageRenderer extends RendererBase {

  /**
   * A specific language code for rendering if available.
   *
   * @var string|null
   */
  protected $langcode;

  /**
   * 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.
   * @param string|null $langcode
   *   A specific language code to set, if available.
   */
  public function __construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type, $langcode) {
    parent::__construct($view, $language_manager, $entity_type);
    $this->langcode = $langcode;
  }

  /**
   * {@inheritdoc}
   */
  public function getLangcode(ResultRow $row) {
    return $this->langcode;
  }

  /**
   * {@inheritdoc}
   */
  public function query(QueryPluginBase $query, $relationship = NULL) {
  }

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $row) {
    $entity_id = $row->_entity
      ->id();
    return $this->build[$entity_id];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableLanguageRenderer::$langcode protected property A specific language code for rendering if available.
ConfigurableLanguageRenderer::getLangcode public function
ConfigurableLanguageRenderer::query public function Alters the query if needed. Overrides RendererBase::query
ConfigurableLanguageRenderer::render public function Renders entity data. Overrides RendererBase::render
ConfigurableLanguageRenderer::__construct public function Constructs a renderer object. Overrides RendererBase::__construct
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. Overrides RendererBase::preRender