You are here

protected function EntityRow::getEntityTranslationRenderer in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/views/row/EntityRow.php \Drupal\ds\Plugin\views\row\EntityRow::getEntityTranslationRenderer()
  2. 8.2 src/Plugin/views/row/EntityRow.php \Drupal\ds\Plugin\views\row\EntityRow::getEntityTranslationRenderer()

Returns the current renderer.

Return value

\Drupal\views\Entity\Render\EntityTranslationRendererBase The configured renderer.

Overrides EntityTranslationRenderTrait::getEntityTranslationRenderer

File

src/Plugin/views/row/EntityRow.php, line 232

Class

EntityRow
Generic entity row plugin to provide a common base for all entity types.

Namespace

Drupal\ds\Plugin\views\row

Code

protected function getEntityTranslationRenderer() {
  if (!isset($this->entityLanguageRenderer)) {
    $view = $this
      ->getView();
    $rendering_language = $view->display_handler
      ->getOption('rendering_language');
    $langcode = NULL;
    $dynamic_renderers = [
      '***LANGUAGE_entity_translation***' => 'TranslationLanguageRenderer',
      '***LANGUAGE_entity_default***' => 'DefaultLanguageRenderer',
    ];
    if (isset($dynamic_renderers[$rendering_language])) {

      // Dynamic language set based on result rows or instance defaults.
      $renderer = $dynamic_renderers[$rendering_language];
    }
    else {
      if (strpos($rendering_language, '***LANGUAGE_') !== FALSE) {
        $langcode = PluginBase::queryLanguageSubstitutions()[$rendering_language];
      }
      else {

        // Specific langcode set.
        $langcode = $rendering_language;
      }
      $renderer = 'ConfigurableLanguageRenderer';
    }
    $class = '\\Drupal\\ds\\Plugin\\views\\Entity\\Render\\' . $renderer;
    $entity_type = \Drupal::service('entity_type.manager')
      ->getDefinition($this
      ->getEntityTypeId());
    $this->entityLanguageRenderer = new $class($view, $this
      ->getLanguageManager(), $entity_type, $langcode);
  }
  return $this->entityLanguageRenderer;
}