bug fixes and subscription improvements

This commit is contained in:
Dennis Eichhorn 2023-04-25 01:51:28 +00:00
parent 94f57e6121
commit 5c4b7d05db
2 changed files with 37 additions and 6 deletions

View File

@ -505,6 +505,20 @@ final class ApiController extends Controller
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Template', 'Template successfully created', $template);
}
/**
* Install a new workflow template.
*
* Some actions have a install function, which must be called when first installing/registering a new action in a template.
* An example could be the cron job for a timed trigger, which must be installed when the template is installed.
*
* @param WorkflowTemplate $template Workflow template
* @param array $actions Actions
*
* @return void
*
* @since 1.0.0
* @todo: also implement the delete and update functions
*/
private function installWorkflowModel(WorkflowTemplate $template, array $actions) : void
{
$schema = $template->schema;
@ -519,9 +533,18 @@ final class ApiController extends Controller
}
}
/**
* Installs a timed trigger for a workflow template.
*
* @param WorkflowTemplate $template Workflow template
*
* @return void
*
* @since 1.0.0
*/
public function installTimedTrigger(WorkflowTemplate $template) : void
{
$id = 'Workflow-' . $template->getId();
$id = 'Workflow-' . $template->getId();
$scheduler = SchedulerFactory::create();
if (!empty($scheduler->getAllByName($id))) {
@ -531,9 +554,9 @@ final class ApiController extends Controller
$job = TaskFactory::create($id);
$job->interval = $template->schema['settings']['interval'] ?? '';
$job->command = 'php '
. FileUtils::absolute(__DIR__ . '/../../../Cli/cli.php')
. ' /workflow/instance -id '
$job->command = 'php '
. FileUtils::absolute(__DIR__ . '/../../../Cli/cli.php')
. ' /workflow/instance -id '
. $template->getId()
. ' -trigger 1005500005';

View File

@ -164,7 +164,7 @@ final class CliController extends Controller
* @param RequestAbstract $request Request
*
* @return WorkflowInstanceAbstract
*
*
* @todo: How to handle workflow instances which are not saved in the database and are continued?
*
* @since 1.0.0
@ -178,7 +178,15 @@ final class CliController extends Controller
$instance = new WorkflowInstance();
$actions = \json_decode(\file_get_contents(__DIR__ . '/../Definitions/actions.json'), true);
$actionString = \file_get_contents(__DIR__ . '/../Definitions/actions.json');
if ($actionString === false) {
return $instance;
}
$actions = \json_decode($actionString, true);
if (!\is_array($actions)) {
return $instance;
}
foreach ($template->schema as $e) {
if ($e['id'] === $request->getDataString('trigger')) {