public function MaestroInteractiveExampleTask::execute in Maestro 8.2
Same name and namespace in other branches
- 3.x modules/examples/maestro_interactive_task_plugin_example/src/Plugin/EngineTasks/MaestroInteractiveExampleTask.php \Drupal\maestro_interactive_task_plugin_example\Plugin\EngineTasks\MaestroInteractiveExampleTask::execute()
Part of the ExecutableInterface Execution of the Example task returns TRUE and does nothing else. .
Overrides ExecutableInterface::execute
File
- modules/
examples/ maestro_interactive_task_plugin_example/ src/ Plugin/ EngineTasks/ MaestroInteractiveExampleTask.php, line 102
Class
- MaestroInteractiveExampleTask
- Maestro Interactive Example Task Plugin.
Namespace
Drupal\maestro_interactive_task_plugin_example\Plugin\EngineTasksCode
public function execute() {
/*
* You can refer to other Maestro task types, however, in this execute method you must do any of the heavy
* lifting required by the task to complete.
*
* Returning TRUE tells the engine you've completed execution properly and the task is complete.
* Return a FALSE to not tell the engine to archive and flag the task as complete.
*/
// We set the run_once flag here. The Run Once flag is located on the queue entity.
// Interactive and content type tasks are executed and completed by the user using the Maestro API, and not completed by the engine.
// If we don't set the run_once flag, the engine will simply run through this execute method on each run of the orchestrator.
// Setting the run_once flag means that the engine will only execute this method the first time after task creation.
// We don't set this field automatically for interactive tasks as there may be a situation that your
// custom task needs to execute something on each engine cycle
// There's currently no API routine to do this as this is so low-level and task specific that
// there was no need to do so.
$queueRecord = \Drupal::entityTypeManager()
->getStorage('maestro_queue')
->load($this->queueID);
$queueRecord
->set('run_once', 1);
$queueRecord
->save();
return TRUE;
}