public function MediaListBuilder::buildRow in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/src/MediaListBuilder.php \Drupal\media\MediaListBuilder::buildRow()
- 9 core/modules/media/src/MediaListBuilder.php \Drupal\media\MediaListBuilder::buildRow()
Builds a row for an entity in the entity listing.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.
Return value
array A render array structure of fields for this entity.
Overrides EntityListBuilder::buildRow
See also
\Drupal\Core\Entity\EntityListBuilder::render()
File
- core/
modules/ media/ src/ MediaListBuilder.php, line 115
Class
- MediaListBuilder
- Provides a listing of media items.
Namespace
Drupal\mediaCode
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\media\MediaInterface $entity */
if ($this->thumbnailStyleExists) {
$row['thumbnail'] = [];
if ($thumbnail_uri = $entity
->getSource()
->getMetadata($entity, 'thumbnail_uri')) {
$row['thumbnail']['data'] = [
'#theme' => 'image_style',
'#style_name' => 'thumbnail',
'#uri' => $thumbnail_uri,
'#height' => 50,
];
}
}
$row['name']['data'] = [
'#type' => 'link',
'#title' => $entity
->label(),
'#url' => $entity
->toUrl(),
];
$row['type'] = $entity->bundle->entity
->label();
$row['author']['data'] = [
'#theme' => 'username',
'#account' => $entity
->getOwner(),
];
$row['status'] = $entity
->isPublished() ? $this
->t('Published') : $this
->t('Unpublished');
$row['changed'] = $this->dateFormatter
->format($entity
->getChangedTime(), 'short');
if ($this->languageManager
->isMultilingual()) {
$row['language'] = $this->languageManager
->getLanguageName($entity
->language()
->getId());
}
return $row + parent::buildRow($entity);
}