DateFormatDeleteForm.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\system\Form;
  3. use Drupal\Core\Datetime\DateFormatterInterface;
  4. use Drupal\Core\Entity\EntityDeleteForm;
  5. use Symfony\Component\DependencyInjection\ContainerInterface;
  6. /**
  7. * Builds a form to delete a date format.
  8. *
  9. * @internal
  10. */
  11. class DateFormatDeleteForm extends EntityDeleteForm {
  12. /**
  13. * The date formatter service.
  14. *
  15. * @var \Drupal\Core\Datetime\DateFormatterInterface
  16. */
  17. protected $dateFormatter;
  18. /**
  19. * Constructs an DateFormatDeleteForm object.
  20. *
  21. * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
  22. * The date formatter service.
  23. */
  24. public function __construct(DateFormatterInterface $date_formatter) {
  25. $this->dateFormatter = $date_formatter;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public static function create(ContainerInterface $container) {
  31. return new static(
  32. $container->get('date.formatter')
  33. );
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function getQuestion() {
  39. return t('Are you sure you want to delete the format %name : %format?', [
  40. '%name' => $this->entity->label(),
  41. '%format' => $this->dateFormatter->format(REQUEST_TIME, $this->entity->id()),
  42. ]);
  43. }
  44. }