simple_paypal_field-8.x-1.1/modules/paypal_field_example/src/Entity/Builder/PaymentListBuilder.php
modules/paypal_field_example/src/Entity/Builder/PaymentListBuilder.php
<?php namespace Drupal\paypal_field_example\Entity\Builder; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListBuilder; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class PaymentListBuilder. */ class PaymentListBuilder extends EntityListBuilder { /** * Date formatter. * * @var \Drupal\Core\Datetime\DateFormatterInterface */ protected $dateFormatter; /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('date.formatter') ); } /** * {@inheritdoc} */ public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $dateFormatter) { parent::__construct($entity_type, $storage); $this->dateFormatter = $dateFormatter; } /** * {@inheritdoc} */ public function buildHeader() { $header = [ 'id' => $this->t('Order Id'), 'date' => $this->t('Added'), ]; return $header + parent::buildHeader(); } /** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { $row['id']['data'] = $entity->order_id->value; $row['date']['data'] = $this->dateFormatter->format($entity->created->value); return $row + parent::buildRow($entity); } }