entity_agree-2.0.x-dev/src/AgreementListBuilder.php
src/AgreementListBuilder.php
<?php namespace Drupal\entity_agree; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; use Drupal\Core\Entity\EntityTypeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * List builder for agreements. */ class AgreementListBuilder extends EntityListBuilder { /** * Entity type manager. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { $builder = parent::createInstance($container, $entity_type); $builder->entityTypeManager = $container->get('entity_type.manager'); return $builder; } /** * {@inheritdoc} */ public function buildHeader() { return [ 'user' => $this->t('User'), 'agreement' => $this->t('Agreement'), 'timestamp' => $this->t('Date/time'), ]; } /** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { /** @var \Drupal\entity_agree\AgreementInterface $entity */ $row = [ 'user' => [ 'data' => [ '#type' => 'link', '#title' => $entity->getOwner()->label(), '#url' => $entity->getOwner()->toUrl(), ], ], 'agreement' => [ 'data' => [ '#type' => 'link', '#title' => $entity->getOwner()->label(), '#url' => $entity->getOwner()->toUrl(), ], ], 'timestamp' => [ 'data' => [ '#type' => 'link', '#title' => $entity->getOwner()->label(), '#url' => $entity->getOwner()->toUrl(), ], ], ]; return $row; } }