f3749e2c4bce99f74349a044a2b4db8d4277d2c5
[yaffs-website] / web / modules / contrib / paragraphs / src / Form / ParagraphsTypeDeleteConfirm.php
1 <?php
2
3 namespace Drupal\paragraphs\Form;
4
5 use Drupal\Core\Entity\EntityDeleteForm;
6 use Drupal\Core\Form\FormStateInterface;
7
8 /**
9  * Provides a form for Paragraphs type deletion.
10  */
11 class ParagraphsTypeDeleteConfirm extends EntityDeleteForm {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function buildForm(array $form, FormStateInterface $form_state) {
17     $num_paragraphs = $this->entityTypeManager->getStorage('paragraph')->getQuery()
18       ->condition('type', $this->entity->id())
19       ->count()
20       ->execute();
21     if ($num_paragraphs) {
22       $caption = '<p>' . $this->formatPlural($num_paragraphs, '%type Paragraphs type is used by 1 piece of content on your site. You can not remove this %type Paragraphs type until you have removed all from the content.', '%type Paragraphs type is used by @count pieces of content on your site. You may not remove %type Paragraphs type until you have removed all from the content.', ['%type' => $this->entity->label()]) . '</p>';
23       $form['#title'] = $this->getQuestion();
24       $form['description'] = ['#markup' => $caption];
25       return $form;
26     }
27
28     return parent::buildForm($form, $form_state);
29   }
30
31 }