You are here

class DataEntityRow in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/rest/src/Plugin/views/row/DataEntityRow.php \Drupal\rest\Plugin\views\row\DataEntityRow
  2. 9 core/modules/rest/src/Plugin/views/row/DataEntityRow.php \Drupal\rest\Plugin\views\row\DataEntityRow

Plugin which displays entities as raw data.

Plugin annotation


@ViewsRow(
  id = "data_entity",
  title = @Translation("Entity"),
  help = @Translation("Use entities as row data."),
  display_types = {"data"}
)

Hierarchy

Expanded class hierarchy of DataEntityRow

File

core/modules/rest/src/Plugin/views/row/DataEntityRow.php, line 24

Namespace

Drupal\rest\Plugin\views\row
View source
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 type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The entity repository service.
   *
   * @var \Drupal\Core\Entity\EntityRepositoryInterface
   */
  protected $entityRepository;

  /**
   * The entity display repository.
   *
   * @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
   */
  protected $entityDisplayRepository;

  /**
   * The language manager.
   *
   * @var \Drupal\Core\Language\LanguageManagerInterface
   */
  protected $languageManager;

  /**
   * 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 $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
   *   The language manager.
   * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
   *   The entity repository.
   */
  public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EntityRepositoryInterface $entity_repository) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->entityTypeManager = $entity_type_manager;
    $this->languageManager = $language_manager;
    $this->entityRepository = $entity_repository;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('entity_type.manager'), $container
      ->get('language_manager'), $container
      ->get('entity.repository'));
  }

  /**
   * {@inheritdoc}
   */
  public function render($row) {
    return $this
      ->getEntityTranslation($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());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DataEntityRow::$entityDisplayRepository protected property The entity display repository.
DataEntityRow::$entityRepository protected property The entity repository service.
DataEntityRow::$entityType protected property Contains the entity type of this row plugin instance.
DataEntityRow::$entityTypeManager protected property The entity type manager.
DataEntityRow::$languageManager protected property The language manager.
DataEntityRow::$usesOptions protected property
DataEntityRow::create public static function
DataEntityRow::getEntityRepository protected function
DataEntityRow::getEntityTypeId public function Returns the entity type identifier. Overrides EntityTranslationRenderTrait::getEntityTypeId
DataEntityRow::getEntityTypeManager protected function
DataEntityRow::getLanguageManager protected function Returns the language manager. Overrides EntityTranslationRenderTrait::getLanguageManager
DataEntityRow::getView protected function Returns the top object of a view. Overrides EntityTranslationRenderTrait::getView
DataEntityRow::query public function
DataEntityRow::render public function
DataEntityRow::__construct public function Constructs a new DataEntityRow object.
EntityTranslationRenderTrait::$entityTranslationRenderer protected property The renderer to be used to render the entity row.
EntityTranslationRenderTrait::getEntityTranslation public function Returns the entity translation matching the configured row language.
EntityTranslationRenderTrait::getEntityTranslationRenderer protected function Returns the current renderer.