public function ProfileTypeDeleteForm::buildForm in Profile 8
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/ ProfileTypeDeleteForm.php, line 16
Class
- ProfileTypeDeleteForm
- Provides a confirmation form for deleting a Profile type entity.
Namespace
Drupal\profile\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$num_profiles = $this->entityTypeManager
->getStorage('profile')
->getQuery()
->accessCheck(FALSE)
->condition('type', $this->entity
->id())
->count()
->execute();
if ($num_profiles) {
$caption = '<p>' . \Drupal::translation()
->formatPlural($num_profiles, '%type is used by 1 profile on your site. You cannot remove this profile type until you have removed all of the %type profiles.', '%type is used by @count profiles on your site. You may not remove %type until you have removed all of the %type profiles.', [
'%type' => $this->entity
->label(),
]) . '</p>';
$form['#title'] = $this
->getQuestion();
$form['description'] = [
'#markup' => $caption,
];
return $form;
}
return parent::buildForm($form, $form_state);
}