DataEntityRow.php

Same filename and directory in other branches
  1. 11.x core/modules/rest/src/Plugin/views/row/DataEntityRow.php
  2. 10 core/modules/rest/src/Plugin/views/row/DataEntityRow.php
  3. 9 core/modules/rest/src/Plugin/views/row/DataEntityRow.php
  4. 8.9.x core/modules/rest/src/Plugin/views/row/DataEntityRow.php

Namespace

Drupal\rest\Plugin\views\row

File

core/modules/rest/src/Plugin/views/row/DataEntityRow.php

View source
<?php

namespace Drupal\rest\Plugin\views\row;

use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsRow;
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
use Drupal\views\Plugin\views\row\RowPluginBase;

/**
 * Plugin which displays entities as raw data.
 *
 * @ingroup views_row_plugins
 */
class DataEntityRow extends RowPluginBase {
  use EntityTranslationRenderTrait;
  
  /**
   * {@inheritdoc}
   */
  protected $usesOptions = FALSE;
  
  /**
   * Contains the entity type of this row plugin instance.
   *
   * @var \Drupal\Core\Entity\EntityTypeInterface
   */
  protected $entityType;
  
  /**
   * The entity display repository.
   *
   * @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
   */
  protected $entityDisplayRepository;
  
  /**
   * Constructs a new DataEntityRow object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin ID for the plugin instance.
   * @param array $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\Core\Language\LanguageManagerInterface $languageManager
   *   The language manager.
   * @param \Drupal\Core\Entity\EntityRepositoryInterface $entityRepository
   *   The entity repository.
   */
  public function __construct(array $configuration, $plugin_id, array $plugin_definition, protected EntityTypeManagerInterface $entityTypeManager, protected LanguageManagerInterface $languageManager, protected EntityRepositoryInterface $entityRepository) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }
  
  /**
   * {@inheritdoc}
   */
  public function render($row) {
    return $this->getEntityTranslationByRelationship($row->_entity, $row);
  }
  
  /**
   * {@inheritdoc}
   */
  public function getEntityTypeId() {
    return $this->view
      ->getBaseEntityType()
      ->id();
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getEntityTypeManager() {
    return $this->entityTypeManager;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getEntityRepository() {
    return $this->entityRepository;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getLanguageManager() {
    return $this->languageManager;
  }
  
  /**
   * {@inheritdoc}
   */
  protected function getView() {
    return $this->view;
  }
  
  /**
   * {@inheritdoc}
   */
  public function query() {
    parent::query();
    $this->getEntityTranslationRenderer()
      ->query($this->view
      ->getQuery());
  }

}

Classes

Title Deprecated Summary
DataEntityRow Plugin which displays entities as raw data.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.