FlaggingCollectionListBuilder.php in Flag Lists 8
File
src/FlaggingCollectionListBuilder.php
View source
<?php
namespace Drupal\flag_lists;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Link;
class FlaggingCollectionListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['name'] = $this
->t('Flagging Collection');
$header['id'] = $this
->t('ID');
$header['bundle']['data'] = $this
->t('Bundle');
$header['templateflag']['data'] = $this
->t('Flag for List');
$header['relatedflag']['data'] = $this
->t('The related flag');
$header['base_flag']['data'] = $this
->t('Template Flag');
$header['owner']['data'] = $this
->t('Owner');
$header['scope']['data'] = $this
->t('Scope');
$header['operations']['data'] = $this
->t('Operations');
return $header;
}
public function buildRow(EntityInterface $entity) {
$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);
}
}
}