public function SimpleMegaMenuTypeDeleteForm::buildForm in Simple Mega Menu 8
Same name and namespace in other branches
- 2.0.x src/Form/SimpleMegaMenuTypeDeleteForm.php \Drupal\simple_megamenu\Form\SimpleMegaMenuTypeDeleteForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EntityDeleteForm::buildForm
File
- src/
Form/ SimpleMegaMenuTypeDeleteForm.php, line 38
Class
- SimpleMegaMenuTypeDeleteForm
- Builds the form to delete Simple mega menu type entities.
Namespace
Drupal\simple_megamenu\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$entities = $this->entityTypeManager
->getStorage('simple_mega_menu')
->getQuery()
->condition('type', $this->entity
->id())
->count()
->execute();
if ($entities) {
$caption = '<p>' . $this
->formatPlural($entities, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', [
'%type' => $this->entity
->label(),
]) . '</p>';
$form['#title'] = $this
->getQuestion();
$form['description'] = [
'#markup' => $caption,
];
return $form;
}
return parent::buildForm($form, $form_state);
}