public function FlagListItemListBuilder::buildRow in Flag Lists 8
Same name and namespace in other branches
- 4.0.x 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_listsCode
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\flag_lists\Entity\FlagListItem */
$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);
}
}