Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Workflows] Schema #623

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/Workflow/Schema/SubmitAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -94,6 +98,6 @@ public function getWorkflowOptions(): array

public function getTransition(): string
{
return $this->transition;
return $this->transitionId;
}
}
7 changes: 6 additions & 1 deletion src/Workflow/Service/WorkflowDetailsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Workflow/Schema/SubmitActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function testSubmitActionException(): void
actionType: 'someUnusualType',
elementId: 1,
elementType: 'object',
workflowName: 'myWorkflow',
transition: 'myTransition',
workflowId: 'myWorkflow',
transitionId: 'myTransition',
workflowOptions: []
);
}
Expand All @@ -48,8 +48,8 @@ public function testSubmitActionElementException(): void
actionType: 'global',
elementId: 1,
elementType: 'someUnusualElementType',
workflowName: 'myWorkflow',
transition: 'myTransition',
workflowId: 'myWorkflow',
transitionId: 'myTransition',
workflowOptions: []
);
}
Expand All @@ -60,8 +60,8 @@ public function testSubmitActionParameters(): void
actionType: 'transition',
elementId: 1,
elementType: 'asset',
workflowName: 'myWorkflow',
transition: 'myTransition',
workflowId: 'myWorkflow',
transitionId: 'myTransition',
workflowOptions: []
);

Expand Down
Loading