You are here

public function FlagListItemListBuilder::buildRow in Flag Lists 4.0.x

Same name and namespace in other branches
  1. 8 src/FlagListItemListBuilder.php \Drupal\flag_lists\FlagListItemListBuilder::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/FlagListItemListBuilder.php, line 30

Class

FlagListItemListBuilder
Defines a class to build a listing of Flag list item entities.

Namespace

Drupal\flag_lists

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\flag_lists\Entity\FlagListItem $entity */
  $account = \Drupal::currentUser()
    ->getAccount();
  $entity_id = $entity
    ->getConnectedEntityId();
  $connectedEntity = \Drupal::entityTypeManager()
    ->getStorage('node')
    ->load($entity_id);
  if ($entity
    ->access('view', $account)) {
    $row['id'] = $entity
      ->id();
    $row['name'] = Link::createFromRoute($entity
      ->label(), 'entity.flag_list_item.edit_form', [
      'flag_list_item' => $entity
        ->id(),
    ]);
    $row['entity_id'] = $entity_id;
    $row['entity_exist']['data'] = empty($connectedEntity) ? "Doesn't exist" : 'Exist';
    $row['entity_exist']['class'] = empty($connectedEntity) ? "entity-missing" : 'entity-exist';
    return $row + parent::buildRow($entity);
  }
}