diff --git a/src/Workflow/Schema/SubmitAction.php b/src/Workflow/Schema/SubmitAction.php index 41840ab6f..7ab54fe81 100644 --- a/src/Workflow/Schema/SubmitAction.php +++ b/src/Workflow/Schema/SubmitAction.php @@ -42,14 +42,14 @@ public function __construct( example: WorkflowActionTypes::TRANSITION_ACTION )] private string $actionType, - #[Property(description: 'id of the element', type: 'integer', example: 50)] + #[Property(description: 'Id of the element', type: 'integer', example: 50)] private int $elementId, - #[Property(description: 'type of the element', type: 'string', example: ElementTypes::TYPE_OBJECT)] + #[Property(description: 'Type of the element', type: 'string', example: ElementTypes::TYPE_DATA_OBJECT)] private string $elementType, - #[Property(description: 'name of the workflow', type: 'string', example: 'my_first_workflow')] - private string $workflowName, - #[Property(description: 'transition', type: 'string', example: 'start_workflow')] - private string $transition, + #[Property(description: 'Id of the workflow', type: 'string', example: 'my_first_workflow')] + private string $workflowId, + #[Property(description: 'Id of the transition', type: 'string', example: 'start_workflow')] + private string $transitionId, #[Property( description: 'workflowOptions', type: 'object', @@ -79,12 +79,16 @@ public function getElementId(): int public function getElementType(): string { + if ($this->elementType === ElementTypes::TYPE_DATA_OBJECT) { + return ElementTypes::TYPE_OBJECT; + } + return $this->elementType; } public function getWorkflowName(): string { - return $this->workflowName; + return $this->workflowId; } public function getWorkflowOptions(): array @@ -94,6 +98,6 @@ public function getWorkflowOptions(): array public function getTransition(): string { - return $this->transition; + return $this->transitionId; } } diff --git a/src/Workflow/Service/WorkflowDetailsService.php b/src/Workflow/Service/WorkflowDetailsService.php index 910100ec6..e4bb1a8ab 100644 --- a/src/Workflow/Service/WorkflowDetailsService.php +++ b/src/Workflow/Service/WorkflowDetailsService.php @@ -29,6 +29,7 @@ use Pimcore\Model\Element\ElementInterface; use Pimcore\Model\UserInterface; use Pimcore\Workflow\Manager; +use Symfony\Component\ExpressionLanguage\SyntaxError; use Symfony\Component\Workflow\WorkflowInterface; use function count; @@ -87,7 +88,11 @@ public function hasElementWorkflowsById(int $elementId, string $elementType, Use public function hasElementWorkflows(ElementInterface $element): bool { - return count($this->workflowManager->getAllWorkflowsForSubject($element)) > 0; + try { + return count($this->workflowManager->getAllWorkflowsForSubject($element)) > 0; + } catch (SyntaxError) { + return false; + } } /** diff --git a/tests/Unit/Workflow/Schema/SubmitActionTest.php b/tests/Unit/Workflow/Schema/SubmitActionTest.php index e6a0cb26a..b9b7b86cc 100644 --- a/tests/Unit/Workflow/Schema/SubmitActionTest.php +++ b/tests/Unit/Workflow/Schema/SubmitActionTest.php @@ -34,8 +34,8 @@ public function testSubmitActionException(): void actionType: 'someUnusualType', elementId: 1, elementType: 'object', - workflowName: 'myWorkflow', - transition: 'myTransition', + workflowId: 'myWorkflow', + transitionId: 'myTransition', workflowOptions: [] ); } @@ -48,8 +48,8 @@ public function testSubmitActionElementException(): void actionType: 'global', elementId: 1, elementType: 'someUnusualElementType', - workflowName: 'myWorkflow', - transition: 'myTransition', + workflowId: 'myWorkflow', + transitionId: 'myTransition', workflowOptions: [] ); } @@ -60,8 +60,8 @@ public function testSubmitActionParameters(): void actionType: 'transition', elementId: 1, elementType: 'asset', - workflowName: 'myWorkflow', - transition: 'myTransition', + workflowId: 'myWorkflow', + transitionId: 'myTransition', workflowOptions: [] );