class DateFormatListBuilder
Same name and namespace in other branches
- 11.x core/modules/system/src/DateFormatListBuilder.php \Drupal\system\DateFormatListBuilder
- 10 core/modules/system/src/DateFormatListBuilder.php \Drupal\system\DateFormatListBuilder
- 8.9.x core/modules/system/src/DateFormatListBuilder.php \Drupal\system\DateFormatListBuilder
Defines a class to build a listing of date format entities.
Hierarchy
- class \Drupal\Core\Entity\EntityHandlerBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Entity\EntityListBuilder implements \Drupal\Core\Entity\EntityListBuilderInterface, \Drupal\Core\Entity\EntityHandlerInterface uses \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait extends \Drupal\Core\Entity\EntityHandlerBase
- class \Drupal\Core\Config\Entity\ConfigEntityListBuilder extends \Drupal\Core\Entity\EntityListBuilder
- class \Drupal\system\DateFormatListBuilder extends \Drupal\Core\Config\Entity\ConfigEntityListBuilder
- class \Drupal\Core\Config\Entity\ConfigEntityListBuilder extends \Drupal\Core\Entity\EntityListBuilder
- class \Drupal\Core\Entity\EntityListBuilder implements \Drupal\Core\Entity\EntityListBuilderInterface, \Drupal\Core\Entity\EntityHandlerInterface uses \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait extends \Drupal\Core\Entity\EntityHandlerBase
Expanded class hierarchy of DateFormatListBuilder
See also
\Drupal\system\Entity\DateFormat
File
-
core/
modules/ system/ src/ DateFormatListBuilder.php, line 17
Namespace
Drupal\systemView source
class DateFormatListBuilder extends ConfigEntityListBuilder {
/**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatterInterface
*/
protected $dateFormatter;
/**
* Constructs a new DateFormatListBuilder object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageInterface $storage
* The entity storage class.
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, DateFormatterInterface $date_formatter) {
parent::__construct($entity_type, $storage);
$this->dateFormatter = $date_formatter;
}
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static($entity_type, $container->get('entity_type.manager')
->getStorage($entity_type->id()), $container->get('date.formatter'));
}
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header['label'] = t('Name');
$header['pattern'] = t('Pattern');
return $header + parent::buildHeader();
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity->label();
$row['pattern'] = $this->dateFormatter
->format(REQUEST_TIME, $entity->id());
return $row + parent::buildRow($entity);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.