public function WorkspaceTypeDeleteForm::buildForm in Workspace 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/
Entity/ Form/ WorkspaceTypeDeleteForm.php, line 44
Class
- WorkspaceTypeDeleteForm
- Provides a confirmation form for deleting a custom workspace type entity.
Namespace
Drupal\workspace\Entity\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$workspaces = $this->queryFactory
->get('workspace')
->condition('type', $this->entity
->id())
->execute();
if (!empty($workspaces)) {
$caption = '<p>' . $this
->formatPlural(count($workspaces), '%label is used by 1 workspace on your site. You can not remove this workspace type until you have removed all of the %label workspaces.', '%label is used by @count workspaces on your site. You may not remove %label until you have removed all of the %label custom workspaces.', [
'%label' => $this->entity
->label(),
]) . '</p>';
$form['description'] = [
'#markup' => $caption,
];
return $form;
}
else {
return parent::buildForm($form, $form_state);
}
}