You are here

public function BrightcovePlaylistListBuilder::buildRow in Brightcove Video Connect 8

Same name and namespace in other branches
  1. 8.2 src/BrightcovePlaylistListBuilder.php \Drupal\brightcove\BrightcovePlaylistListBuilder::buildRow()
  2. 3.x src/BrightcovePlaylistListBuilder.php \Drupal\brightcove\BrightcovePlaylistListBuilder::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/BrightcovePlaylistListBuilder.php, line 103

Class

BrightcovePlaylistListBuilder
Defines a class to build a listing of Brightcove Playlists.

Namespace

Drupal\brightcove

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\brightcove\Entity\BrightcovePlaylist */
  if ($entity
    ->isPublished() && $this->accountProxy
    ->hasPermission('view published brightcove playlists') || !$entity
    ->isPublished() && $this->accountProxy
    ->hasPermission('view unpublished brightcove playlists')) {
    $name = $this
      ->l($entity
      ->label(), new Url('entity.brightcove_playlist.canonical', [
      'brightcove_playlist' => $entity
        ->id(),
    ]));
  }
  else {
    $name = $entity
      ->label();
  }

  // Assemble row.
  $row = [
    'name' => $name,
    'updated' => $this->dateFormatter
      ->format($entity
      ->getChangedTime(), 'short'),
    'reference_id' => $entity
      ->getReferenceId(),
  ];

  // Add operations column only if the user has access.
  if ($this->accountProxy
    ->hasPermission('edit brightcove playlists') || $this->accountProxy
    ->hasPermission('delete brightcove playlists')) {
    $row += parent::buildRow($entity);
  }
  return $row;
}