public function MaestroTemplateDeleteForm::submitForm in Maestro 8.2
Same name and namespace in other branches
- 3.x src/Form/MaestroTemplateDeleteForm.php \Drupal\maestro\Form\MaestroTemplateDeleteForm::submitForm()
The submit handler for the confirm form.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The form's form state.
Overrides EntityForm::submitForm
File
- src/
Form/ MaestroTemplateDeleteForm.php, line 85
Class
- MaestroTemplateDeleteForm
- Class MaestroTemplateDeleteForm.
Namespace
Drupal\maestro\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Delete all open processes with this template.
$query = \Drupal::entityQuery('maestro_process')
->condition('template_id', $this->entity->id);
$entityIDs = $query
->execute();
foreach ($entityIDs as $processID) {
MaestroEngine::deleteProcess($processID);
}
// Delete the entity.
$this->entity
->delete();
// Set a message that the entity was deleted.
\Drupal::messenger()
->addMessage(t('Template %label was deleted.', [
'%label' => $this->entity
->label(),
]));
// Redirect the user to the list controller when complete.
$form_state
->setRedirect('entity.maestro_template.list');
}