MaestroAndTask.php in Maestro 3.x
File
src/Plugin/EngineTasks/MaestroAndTask.php
View source
<?php
namespace Drupal\maestro\Plugin\EngineTasks;
use Drupal\Core\Plugin\PluginBase;
use Drupal\maestro\MaestroEngineTaskInterface;
use Drupal\maestro\MaestroTaskTrait;
use Drupal\maestro\Engine\MaestroEngine;
use Drupal\Core\Form\FormStateInterface;
use Drupal\maestro\Form\MaestroExecuteInteractive;
class MaestroAndTask extends PluginBase implements MaestroEngineTaskInterface {
use MaestroTaskTrait;
public function __construct($configuration = NULL) {
if (is_array($configuration)) {
$this->processID = $configuration[0];
$this->queueID = $configuration[1];
}
}
public function isInteractive() {
return FALSE;
}
public function shortDescription() {
return t('And Task');
}
public function description() {
return $this
->t('And Task.');
}
public function getPluginId() {
return 'MaestroAnd';
}
public function getTaskColours() {
return '#daa520';
}
public function execute() {
$templateMachineName = MaestroEngine::getTemplateIdFromProcessId($this->processID);
$taskMachineName = MaestroEngine::getTaskIdFromQueueId($this->queueID);
$pointers = MaestroEngine::getTaskPointersFromTemplate($templateMachineName, $taskMachineName);
$query = \Drupal::entityQuery('maestro_queue');
$andMainConditions = $query
->andConditionGroup()
->condition('status', '1')
->condition('archived', '2', '!=')
->condition('process_id', $this->processID);
$orConditionGroup = $query
->orConditionGroup();
foreach ($pointers as $taskID) {
$orConditionGroup
->condition('task_id', $taskID);
}
$andMainConditions
->condition($orConditionGroup);
$query
->condition($andMainConditions);
$queueIdCount = $query
->count()
->execute();
if (count($pointers) == $queueIdCount) {
return TRUE;
}
return FALSE;
}
public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {
}
public function handleExecuteSubmit(array &$form, FormStateInterface $form_state) {
}
public function getTaskEditForm(array $task, $templateMachineName) {
return [];
}
public function validateTaskEditForm(array &$form, FormStateInterface $form_state) {
}
public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) {
}
public function performValidityCheck(array &$validation_failure_tasks, array &$validation_information_tasks, array $task) {
}
public function getTemplateBuilderCapabilities() {
return [
'edit',
'drawlineto',
'removelines',
'remove',
];
}
}