public function CommentedEntity::getItems in Drupal 9
Same name and namespace in other branches
- 8 core/modules/comment/src/Plugin/views/field/CommentedEntity.php \Drupal\comment\Plugin\views\field\CommentedEntity::getItems()
- 10 core/modules/comment/src/Plugin/views/field/CommentedEntity.php \Drupal\comment\Plugin\views\field\CommentedEntity::getItems()
Gets an array of items for the field.
Parameters
\Drupal\views\ResultRow $values: The result row object containing the values.
Return value
array An array of items for the field.
Overrides EntityField::getItems
File
- core/
modules/ comment/ src/ Plugin/ views/ field/ CommentedEntity.php, line 28
Class
- CommentedEntity
- Views field display for commented entity.
Namespace
Drupal\comment\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
if (empty($this->loadedCommentedEntities)) {
$result = $this->view->result;
$entity_ids_per_type = [];
foreach ($result as $value) {
/** @var \Drupal\comment\CommentInterface $comment */
if ($comment = $this
->getEntity($value)) {
$entity_ids_per_type[$comment
->getCommentedEntityTypeId()][] = $comment
->getCommentedEntityId();
}
}
foreach ($entity_ids_per_type as $type => $ids) {
$this->loadedCommentedEntities[$type] = $this->entityTypeManager
->getStorage($type)
->loadMultiple($ids);
}
}
return parent::getItems($values);
}