You are here

public function WorkspaceListBuilder::buildRow in Workspace 8

Same name and namespace in other branches
  1. 8.2 src/WorkspaceListBuilder.php \Drupal\workspace\WorkspaceListBuilder::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/WorkspaceListBuilder.php, line 61

Class

WorkspaceListBuilder
Defines a class to build a listing of workspace entities.

Namespace

Drupal\workspace

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\multiversion\Entity\WorkspaceInterface $entity */
  $row['label'] = $entity
    ->label() . ' (' . $entity
    ->getMachineName() . ')';
  $row['owner'] = $entity
    ->getOwner()
    ->getDisplayname();

  /** @var \Drupal\multiversion\Entity\WorkspaceTypeInterface $type */
  $type = $entity
    ->get('type')
    ->first()->entity;
  $row['type'] = $type ? $type
    ->label() : '';
  $active_workspace = $this->workspaceManager
    ->getActiveWorkspaceId();
  $row['status'] = $active_workspace == $entity
    ->id() ? 'Active' : 'Inactive';
  return $row + parent::buildRow($entity);
}