MaestroTraceDeleteProcess.php in Maestro 3.x
File
src/Form/MaestroTraceDeleteProcess.php
View source
<?php
namespace Drupal\maestro\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\maestro\Engine\MaestroEngine;
class MaestroTraceDeleteProcess extends ConfirmFormBase {
protected $id;
protected $processID;
protected $templateName;
public function getFormId() {
return 'maestro_trace_delete_process';
}
public function getQuestion() {
return t('Do you want to delete this instance (Process: %pid) of the workflow: %template?', [
'%pid' => $this->processID,
'%template' => $this->templateName,
]);
}
public function getCancelUrl() {
return new Url('maestro.trace', [
'processID' => $this->processID,
]);
}
public function getDescription() {
return $this
->t('This will remove all the tasks and the process from the queue!');
}
public function getConfirmText() {
return $this
->t('Delete Queue Items Now and process records now!');
}
public function getCancelText() {
return $this
->t('Cancel');
}
public function buildForm(array $form, FormStateInterface $form_state, $processID = NULL, $idList = NULL) {
$this->id = $idList;
$this->processID = $processID;
$this->templateName = MaestroEngine::getTemplateIdFromProcessId($processID);
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
MaestroEngine::deleteProcess($this->processID);
\Drupal::messenger()
->addMessage(t('Process and Task history successfully deleted'));
$form_state
->setRedirect('view.maestro_outstanding_tasks.maestro_outstanding_tasks');
}
}