You are here

public function WorkspaceListBuilder::buildRow in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/workspaces/src/WorkspaceListBuilder.php \Drupal\workspaces\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

core/modules/workspaces/src/WorkspaceListBuilder.php, line 106

Class

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

Namespace

Drupal\workspaces

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\workspaces\WorkspaceInterface $entity */
  if (isset($entity->_depth) && $entity->_depth > 0) {
    $indentation = [
      '#theme' => 'indentation',
      '#size' => $entity->_depth,
    ];
  }
  $row['data'] = [
    'label' => [
      'data' => [
        '#prefix' => isset($indentation) ? $this->renderer
          ->render($indentation) : '',
        '#type' => 'link',
        '#title' => $entity
          ->label(),
        '#url' => $entity
          ->toUrl(),
      ],
    ],
    'owner' => $entity
      ->getOwner()
      ->getDisplayname(),
  ];
  $row['data'] = $row['data'] + parent::buildRow($entity);
  $active_workspace = $this->workspaceManager
    ->getActiveWorkspace();
  if ($active_workspace && $entity
    ->id() === $active_workspace
    ->id()) {
    $row['class'] = [
      'active-workspace',
      'active-workspace--not-default',
    ];
  }
  return $row;
}