public function BrightcoveVideoListBuilder::buildRow in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/BrightcoveVideoListBuilder.php \Drupal\brightcove\BrightcoveVideoListBuilder::buildRow()
- 3.x src/BrightcoveVideoListBuilder.php \Drupal\brightcove\BrightcoveVideoListBuilder::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
- src/
BrightcoveVideoListBuilder.php, line 108
Class
- BrightcoveVideoListBuilder
- Defines a class to build a listing of Brightcove Videos.
Namespace
Drupal\brightcoveCode
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\brightcove\Entity\BrightcoveVideo */
if ($entity
->isPublished() && $this->accountProxy
->hasPermission('view published brightcove videos') || !$entity
->isPublished() && $this->accountProxy
->hasPermission('view unpublished brightcove videos')) {
$name = $this
->l($entity
->label(), new Url('entity.brightcove_video.canonical', [
'brightcove_video' => $entity
->id(),
]));
}
else {
$name = $entity
->label();
}
// Get thumbnail image style and render it.
$thumbnail = $entity
->getThumbnail();
$thumbnail_image = '';
if (!empty($thumbnail['target_id'])) {
/** @var \Drupal\file\Entity\File $thumbnail_file */
$thumbnail_file = File::load($thumbnail['target_id']);
/** @var \Drupal\image\Entity\ImageStyle $image_style */
$image_style = ImageStyle::load('brightcove_videos_list_thumbnail');
if (!empty($thumbnail_file) && !is_null($image_style)) {
$image_uri = $image_style
->buildUrl($thumbnail_file
->getFileUri());
$thumbnail_image = "<img src='{$image_uri}' alt='{$entity->getName()}'>";
}
}
// Assemble row.
$row = [
'video' => [
'data' => [
'#markup' => $thumbnail_image,
],
],
'name' => $name,
'status' => $entity
->isPublished() ? $this
->t('Active') : $this
->t('Inactive'),
'updated' => $this->dateFormatter
->format($entity
->getChangedTime(), 'short'),
'reference_id' => $entity
->getReferenceId(),
'created' => $this->dateFormatter
->format($entity
->getCreatedTime(), 'short'),
];
// Add operations column only if the user has access.
if ($this->accountProxy
->hasPermission('edit brightcove videos') || $this->accountProxy
->hasPermission('delete brightcove videos')) {
$row += parent::buildRow($entity);
}
return $row;
}