3 namespace Drupal\system;
5 use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
6 use Drupal\Core\Datetime\DateFormatterInterface;
7 use Drupal\Core\Entity\EntityInterface;
8 use Drupal\Core\Entity\EntityStorageInterface;
9 use Drupal\Core\Entity\EntityTypeInterface;
10 use Symfony\Component\DependencyInjection\ContainerInterface;
13 * Defines a class to build a listing of date format entities.
15 * @see \Drupal\system\Entity\DateFormat
17 class DateFormatListBuilder extends ConfigEntityListBuilder {
20 * The date formatter service.
22 * @var \Drupal\Core\Datetime\DateFormatterInterface
24 protected $dateFormatter;
27 * Constructs a new DateFormatListBuilder object.
29 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
30 * The entity type definition.
31 * @param \Drupal\Core\Entity\EntityStorageInterface $storage
32 * The entity storage class.
33 * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
34 * The date formatter service.
36 public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter) {
37 parent::__construct($entity_type, $storage);
39 $this->dateFormatter = $date_formatter;
45 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
48 $container->get('entity.manager')->getStorage($entity_type->id()),
49 $container->get('date.formatter')
56 public function buildHeader() {
57 $header['label'] = t('Name');
58 $header['pattern'] = t('Pattern');
59 return $header + parent::buildHeader();
65 public function buildRow(EntityInterface $entity) {
66 $row['label'] = $entity->label();
67 $row['pattern'] = $this->dateFormatter->format(REQUEST_TIME, $entity->id());
68 return $row + parent::buildRow($entity);