From 73b4c65bc8c283bcc7ed03467d98cb5b3979615e Mon Sep 17 00:00:00 2001 From: Dmitriy Krivopalov Date: Mon, 25 Mar 2024 14:09:06 +0300 Subject: [PATCH] Task add finally handler after canceled (#56) --- src/service/action/ActionCancel.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/service/action/ActionCancel.php b/src/service/action/ActionCancel.php index c9c76a6..dd5ac1c 100644 --- a/src/service/action/ActionCancel.php +++ b/src/service/action/ActionCancel.php @@ -8,6 +8,7 @@ use kuaukutsu\poc\task\dto\StageModelState; use kuaukutsu\poc\task\dto\TaskModelState; use kuaukutsu\poc\task\handler\TaskFactory; +use kuaukutsu\poc\task\handler\TaskFinallyHandler; use kuaukutsu\poc\task\service\StageCommand; use kuaukutsu\poc\task\service\TaskCommand; use kuaukutsu\poc\task\state\TaskStateError; @@ -23,6 +24,7 @@ public function __construct( private StageCommand $stageCommand, private TaskCommand $taskCommand, private TaskFactory $factory, + private TaskFinallyHandler $finallyHandler, private TransitionState $transition, ) { } @@ -55,8 +57,16 @@ public function execute(EntityTask $task, ?TaskStateInterface $state = null): En ); } - return $this->factory->create( + $task = $this->factory->create( $this->taskCommand->state($uuid, new TaskModelState($state)) ); + + $this->finallyHandler->handle( + $task->getUuid(), + $task->getOptions(), + $task->getState(), + ); + + return $task; } }