MaestroTraceDeleteTask.php in Maestro 3.x
File
src/Form/MaestroTraceDeleteTask.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 MaestroTraceDeleteTask extends ConfirmFormBase {
protected $id;
protected $processID;
public function getFormId() {
return 'maestro_trace_delete_task';
}
public function getQuestion() {
return t('Do you want to delete Queue Item(s) %id?', [
'%id' => $this->id,
]);
}
public function getCancelUrl() {
return new Url('maestro.trace', [
'processID' => $this->processID,
]);
}
public function getDescription() {
return $this
->t('This will remove the tasks from the queue! This may cause damage to the executing workflow!');
}
public function getConfirmText() {
return $this
->t('Delete Queue Items 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;
return parent::buildForm($form, $form_state);
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$ids = explode(',', $this->id);
foreach ($ids as $queueID) {
if ($queueID != '') {
$queueRecord = MaestroEngine::getQueueEntryById($queueID);
$queueRecord
->delete();
}
}
$form_state
->setRedirect('maestro.trace', [
'processID' => $this->processID,
]);
}
}