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.
13 class MediaTypeDeleteConfirmForm extends EntityDeleteForm {
16 * The entity type manager.
18 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
20 protected $entityTypeManager;
23 * Constructs a new MediaTypeDeleteConfirm object.
25 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
26 * The entity type manager.
28 public function __construct(EntityTypeManagerInterface $entity_type_manager) {
29 $this->entityTypeManager = $entity_type_manager;
35 public static function create(ContainerInterface $container) {
37 $container->get('entity_type.manager')
44 public function buildForm(array $form, FormStateInterface $form_state) {
45 $num_entities = $this->entityTypeManager->getStorage('media')->getQuery()
46 ->condition('bundle', $this->entity->id())
50 $form['#title'] = $this->getQuestion();
51 $form['description'] = [
52 '#type' => 'inline_template',
53 '#template' => '<p>{{ message }}</p>',
55 'message' => $this->formatPlural($num_entities,
56 '%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.',
57 '%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.',
58 ['%type' => $this->entity->label()]),
65 return parent::buildForm($form, $form_state);