X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fmedia%2Fsrc%2FForm%2FMediaTypeDeleteConfirmForm.php;fp=web%2Fcore%2Fmodules%2Fmedia%2Fsrc%2FForm%2FMediaTypeDeleteConfirmForm.php;h=a181858b86309acd7a8372ad626ef947efd94107;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=0000000000000000000000000000000000000000;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/media/src/Form/MediaTypeDeleteConfirmForm.php b/web/core/modules/media/src/Form/MediaTypeDeleteConfirmForm.php new file mode 100644 index 000000000..a181858b8 --- /dev/null +++ b/web/core/modules/media/src/Form/MediaTypeDeleteConfirmForm.php @@ -0,0 +1,68 @@ +entityTypeManager = $entity_type_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('entity_type.manager') + ); + } + + /** + * {@inheritdoc} + */ + public function buildForm(array $form, FormStateInterface $form_state) { + $num_entities = $this->entityTypeManager->getStorage('media')->getQuery() + ->condition('bundle', $this->entity->id()) + ->count() + ->execute(); + if ($num_entities) { + $form['#title'] = $this->getQuestion(); + $form['description'] = [ + '#type' => 'inline_template', + '#template' => '

{{ message }}

', + '#context' => [ + 'message' => $this->formatPlural($num_entities, + '%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.', + '%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.', + ['%type' => $this->entity->label()]), + ], + ]; + + return $form; + } + + return parent::buildForm($form, $form_state); + } + +}