From 05dc7bfaeb027be194a18a0a6c162a7c4e57e6ba Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Tue, 13 Jun 2023 18:55:52 +0000 Subject: [PATCH] Quick backup before crash --- Admin/Installer.php | 10 ++++++++++ Controller/ApiController.php | 18 ++++++++++++++---- Controller/CliController.php | 30 +++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/Admin/Installer.php b/Admin/Installer.php index 10ebfee..ed0fdca 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -95,6 +95,16 @@ final class Installer extends InstallerAbstract return []; } + /** + * Create a workflow template + * + * @param ApplicationAbstract $app Application + * @param array $data Workflow schemas + * + * @return void + * + * @since 1.0.0 + */ private static function createWorkflows(ApplicationAbstract $app, array $data) : void { /** @var \Modules\Workflow\Controller\ApiController $module */ diff --git a/Controller/ApiController.php b/Controller/ApiController.php index edd93bd..fd2efa9 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -399,8 +399,6 @@ final class ApiController extends Controller $request->header->account ); - var_dump($collection->id); - if ($collection->id === 0) { $response->header->status = RequestStatusCode::R_403; $this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Template', 'Couldn\'t create collection for template', null); @@ -440,9 +438,21 @@ final class ApiController extends Controller } // perform other workflow installation actions - $actions = \json_decode(\file_get_contents(__DIR__ . '/../Definitions/actions.json'), true); - $this->installWorkflowModel($template, $actions); + $actionContent = \file_get_contents(__DIR__ . '/../Definitions/actions.json'); + if ($actionContent === false) { + $this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Template', 'Template creation failed', $template); + return; + } + + $actions = \json_decode(\file_get_contents(__DIR__ . '/../Definitions/actions.json'), true); + if (!\is_array($actions)) { + $this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Template', 'Template creation failed', $template); + + return; + } + + $this->installWorkflowModel($template, $actions); $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Template', 'Template successfully created', $template); } diff --git a/Controller/CliController.php b/Controller/CliController.php index 90915b3..7693daf 100755 --- a/Controller/CliController.php +++ b/Controller/CliController.php @@ -168,16 +168,27 @@ final class CliController extends Controller return $instance; } - private function startInstance(RequestAbstract $request, ResponseAbstract $response, WorkflowInstanceAbstract $instance) + /** + * Start a workflow instance + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param WorkflowInstanceAbstract $instance Workflow instance + * + * @return void + * + * @since 1.0.0 + */ + private function startInstance(RequestAbstract $request, ResponseAbstract $response, WorkflowInstanceAbstract $instance) : void { $actionString = \file_get_contents(__DIR__ . '/../Definitions/actions.json'); if ($actionString === false) { - return $instance; + return; } $actions = \json_decode($actionString, true); if (!\is_array($actions)) { - return $instance; + return; } foreach ($instance->template->schema as $e) { @@ -189,6 +200,19 @@ final class CliController extends Controller } } + /** + * Run a workflow element + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param array $actions All available actions + * @param WorkflowInstanceAbstract $instance Current workflow instance + * @param array $element Workflow element to run + * + * @return void + * + * @since 1.0.0 + */ public function runWorkflowElement( RequestAbstract $request, ResponseAbstract $response, array $actions, WorkflowInstanceAbstract $instance, array $element