public function FlaggingCollectionListBuilder::buildRow in Flag Lists 8
Same name and namespace in other branches
- 4.0.x src/FlaggingCollectionListBuilder.php \Drupal\flag_lists\FlaggingCollectionListBuilder::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/
FlaggingCollectionListBuilder.php, line 38  
Class
- FlaggingCollectionListBuilder
 - Defines a class to build a listing of Flagging collection entities.
 
Namespace
Drupal\flag_listsCode
public function buildRow(EntityInterface $entity) {
  /* @var $entity \Drupal\flag_lists\Entity\FlaggingCollection */
  $baseflag = $entity
    ->getBaseFlag();
  $relatedflag = $entity
    ->getRelatedFlag();
  $flagListService = \Drupal::service('flaglists');
  $flag = $flagListService
    ->getFlagForListById($baseflag
    ->id());
  $account = \Drupal::currentUser()
    ->getAccount();
  if ($entity
    ->access('view', $account)) {
    $row = [];
    $row['name'] = Link::createFromRoute($entity
      ->label(), 'entity.flagging_collection.edit_form', [
      'flagging_collection' => $entity
        ->id(),
    ]);
    $row['id'] = $entity
      ->id();
    $row['bundle'] = Link::createFromRoute($flagListService
      ->getFlaggingCollectionTypeById($entity
      ->bundle())
      ->label(), 'entity.flagging_collection_type.collection');
    $row['templateflag'] = Link::createFromRoute($flagListService
      ->getFlagForListById($baseflag
      ->id())
      ->label(), 'entity.flag_for_list.collection');
    $row['relatedflag'] = $relatedflag
      ->label();
    $row['base_flag'] = $baseflag
      ->label();
    $row['owner'] = $entity
      ->getOwner()
      ->label();
    $row['scope'] = $baseflag
      ->isGlobal() ? $this
      ->t('Global') : $this
      ->t('Personal');
    return $row + parent::buildRow($entity);
  }
}