3 namespace Drupal\rest\Plugin\views\row;
5 use Drupal\Core\Entity\EntityManagerInterface;
6 use Drupal\Core\Language\LanguageManagerInterface;
7 use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
8 use Drupal\views\Plugin\views\row\RowPluginBase;
9 use Symfony\Component\DependencyInjection\ContainerInterface;
12 * Plugin which displays entities as raw data.
14 * @ingroup views_row_plugins
18 * title = @Translation("Entity"),
19 * help = @Translation("Use entities as row data."),
20 * display_types = {"data"}
23 class DataEntityRow extends RowPluginBase {
25 use EntityTranslationRenderTrait;
30 protected $usesOptions = FALSE;
33 * Contains the entity type of this row plugin instance.
35 * @var \Drupal\Core\Entity\EntityTypeInterface
37 protected $entityType;
42 * @var \Drupal\Core\Entity\EntityManagerInterface
44 public $entityManager;
47 * The language manager.
49 * @var \Drupal\Core\Language\LanguageManagerInterface
51 protected $languageManager;
56 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
58 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
59 * The language manager.
61 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
62 parent::__construct($configuration, $plugin_id, $plugin_definition);
64 $this->entityManager = $entity_manager;
65 $this->languageManager = $language_manager;
71 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
72 return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('language_manager'));
78 public function render($row) {
79 return $this->getEntityTranslation($row->_entity, $row);
85 public function getEntityTypeId() {
86 return $this->view->getBaseEntityType()->id();
92 protected function getEntityManager() {
93 return $this->entityManager;
99 protected function getLanguageManager() {
100 return $this->languageManager;
106 protected function getView() {
113 public function query() {
115 $this->getEntityTranslationRenderer()->query($this->view->getQuery());