3 namespace Drupal\media\Form;
5 use Drupal\Core\Entity\EntityTypeManagerInterface;
6 use Drupal\Core\Entity\EntityDeleteForm;
7 use Drupal\Core\Form\FormStateInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Provides a form for media type deletion.
15 class MediaTypeDeleteConfirmForm extends EntityDeleteForm {
18 * The entity type manager.
20 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
22 protected $entityTypeManager;
25 * Constructs a new MediaTypeDeleteConfirm object.
27 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
28 * The entity type manager.
30 public function __construct(EntityTypeManagerInterface $entity_type_manager) {
31 $this->entityTypeManager = $entity_type_manager;
37 public static function create(ContainerInterface $container) {
39 $container->get('entity_type.manager')
46 public function buildForm(array $form, FormStateInterface $form_state) {
47 $num_entities = $this->entityTypeManager->getStorage('media')->getQuery()
48 ->condition('bundle', $this->entity->id())
52 $form['#title'] = $this->getQuestion();
53 $form['description'] = [
54 '#type' => 'inline_template',
55 '#template' => '<p>{{ message }}</p>',
57 'message' => $this->formatPlural($num_entities,
58 '%type is used by @count media item on your site. You can not remove this media type until you have removed all of the %type media items.',
59 '%type is used by @count media items on your site. You can not remove this media type until you have removed all of the %type media items.',
60 ['%type' => $this->entity->label()]),
67 return parent::buildForm($form, $form_state);