Skip to content

Commit 706ce58

Browse files
committed
Merge branch '2026.1' into 2026.x
2 parents dfd0e26 + 0444782 commit 706ce58

14 files changed

Lines changed: 701 additions & 0 deletions

config/element_workflow.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ services:
2323
Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowGraphServiceInterface:
2424
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowGraphService
2525

26+
Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsServiceInterface:
27+
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsService
28+
29+
# Repositories
30+
Pimcore\Bundle\StudioBackendBundle\Workflow\Repository\WorkflowElementsRepositoryInterface:
31+
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Repository\WorkflowElementsRepository
32+
2633
# Hydrators
2734

2835
Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator\AllowedTransitionsHydratorInterface:
@@ -34,6 +41,9 @@ services:
3441
Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator\WorkflowDetailsHydratorInterface:
3542
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator\WorkflowDetailsHydrator
3643

44+
Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator\WorkflowElementsHydratorInterface:
45+
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator\WorkflowElementsHydrator
46+
3747
# Submitters
3848
Pimcore\Bundle\StudioBackendBundle\Workflow\ActionSubmitter\TransitionActionSubmitterInterface:
3949
class: Pimcore\Bundle\StudioBackendBundle\Workflow\ActionSubmitter\TransitionActionSubmitter

doc/03_Extending/02_Additional_and_Custom_Attributes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ For more details and frontend customization options, see the
269269
- `pre_response.user_tree_node`
270270
- `pre_response.version`
271271
- `pre_response.website_settings.item`
272+
- `pre_response.workflow_element`
272273
- `pre_response.workflow_details`
273274
- `pre_response.notification_recipient`
274275
- `pre_response.php_code_transformer`
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Property;
15+
16+
use OpenApi\Attributes\Items;
17+
use OpenApi\Attributes\Property;
18+
use Pimcore\Bundle\StudioBackendBundle\Workflow\Schema\WorkflowElement;
19+
20+
/**
21+
* @internal
22+
*/
23+
final class WorkflowElementCollection extends Property
24+
{
25+
public function __construct()
26+
{
27+
parent::__construct(
28+
'items',
29+
title: 'items',
30+
type: 'array',
31+
items: new Items(ref: WorkflowElement::class)
32+
);
33+
}
34+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Controller;
15+
16+
use OpenApi\Attributes\Get;
17+
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
18+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\PageParameter;
19+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\PageSizeParameter;
20+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\StringParameter;
21+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\CollectionJson;
22+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
23+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
24+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
25+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
26+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
27+
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait;
28+
use Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Property\WorkflowElementCollection;
29+
use Pimcore\Bundle\StudioBackendBundle\Workflow\MappedParameter\WorkflowElementsParameters;
30+
use Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsServiceInterface;
31+
use Symfony\Component\HttpFoundation\JsonResponse;
32+
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
33+
use Symfony\Component\Routing\Attribute\Route;
34+
use Symfony\Component\Security\Http\Attribute\IsGranted;
35+
use Symfony\Component\Serializer\SerializerInterface;
36+
37+
/**
38+
* @internal
39+
*/
40+
final class ElementsController extends AbstractApiController
41+
{
42+
use PaginatedResponseTrait;
43+
44+
private const string ROUTE = '/workflows/elements';
45+
46+
public function __construct(
47+
SerializerInterface $serializer,
48+
private readonly WorkflowElementsServiceInterface $workflowElementsService,
49+
) {
50+
parent::__construct($serializer);
51+
}
52+
53+
#[Route(
54+
path: self::ROUTE,
55+
name: 'pimcore_studio_api_element_workflows_elements',
56+
methods: ['GET']
57+
)]
58+
#[IsGranted(UserPermissions::ELEMENT_TYPE_PERMISSION->value)]
59+
#[Get(
60+
path: self::PREFIX . self::ROUTE,
61+
operationId: 'workflow_get_elements',
62+
description: 'workflow_get_elements_description',
63+
summary: 'workflow_get_elements_summary',
64+
tags: [Tags::Workflows->name]
65+
)]
66+
#[StringParameter('workflowName', 'product_workflow', 'Workflow name')]
67+
#[StringParameter('stateName', 'in_review', 'Workflow state / place name', required: false)]
68+
#[StringParameter('elementType', 'asset', 'Element type (asset or data-object)', required: false)]
69+
#[PageParameter]
70+
#[PageSizeParameter(50)]
71+
#[SuccessResponse(
72+
description: 'workflow_get_elements_success_response',
73+
content: new CollectionJson(new WorkflowElementCollection())
74+
)]
75+
#[DefaultResponses([
76+
HttpResponseCodes::UNAUTHORIZED,
77+
HttpResponseCodes::INTERNAL_SERVER_ERROR,
78+
])]
79+
public function getElements(
80+
#[MapQueryString] WorkflowElementsParameters $parameters = new WorkflowElementsParameters()
81+
): JsonResponse {
82+
$collection = $this->workflowElementsService->getElements($parameters);
83+
84+
return $this->getPaginatedCollection(
85+
$this->serializer,
86+
$collection->getItems(),
87+
$collection->getTotalItems()
88+
);
89+
}
90+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Event\PreResponse;
15+
16+
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;
17+
use Pimcore\Bundle\StudioBackendBundle\Workflow\Schema\WorkflowElement;
18+
19+
final class WorkflowElementEvent extends AbstractPreResponseEvent
20+
{
21+
public const string EVENT_NAME = 'pre_response.workflow_element';
22+
23+
public function __construct(
24+
private readonly WorkflowElement $workflowElement
25+
) {
26+
parent::__construct($this->workflowElement);
27+
}
28+
29+
/**
30+
* Use this to get additional info out of the response object
31+
*/
32+
public function getWorkflowElement(): WorkflowElement
33+
{
34+
return $this->workflowElement;
35+
}
36+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator;
15+
16+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementTypes;
17+
use Pimcore\Bundle\StudioBackendBundle\Workflow\Schema\WorkflowElement;
18+
use Pimcore\Model\Element\ElementInterface;
19+
20+
/**
21+
* @internal
22+
*/
23+
final readonly class WorkflowElementsHydrator implements WorkflowElementsHydratorInterface
24+
{
25+
public function hydrate(
26+
ElementInterface $element,
27+
array $row,
28+
string $workflowName,
29+
string $stateName,
30+
string $stateLabel,
31+
string $stateColor,
32+
): WorkflowElement {
33+
$ctype = (string) $row['ctype'];
34+
35+
return new WorkflowElement(
36+
(int) $row['cid'],
37+
$ctype === ElementTypes::TYPE_OBJECT ? ElementTypes::TYPE_DATA_OBJECT : $ctype,
38+
$element->getFullPath(),
39+
$element->getKey(),
40+
$workflowName,
41+
$stateName,
42+
$stateLabel,
43+
$stateColor,
44+
$element->getModificationDate() ?? (int) $row['modificationDate'],
45+
);
46+
}
47+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Hydrator;
15+
16+
use Pimcore\Bundle\StudioBackendBundle\Workflow\Schema\WorkflowElement;
17+
use Pimcore\Model\Element\ElementInterface;
18+
19+
/**
20+
* @internal
21+
*/
22+
interface WorkflowElementsHydratorInterface
23+
{
24+
/**
25+
* @param array<string, mixed> $row
26+
*/
27+
public function hydrate(
28+
ElementInterface $element,
29+
array $row,
30+
string $workflowName,
31+
string $stateName,
32+
string $stateLabel,
33+
string $stateColor,
34+
): WorkflowElement;
35+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* This source file is available under the terms of the
6+
* Pimcore Open Core License (POCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
11+
* @license Pimcore Open Core License (POCL)
12+
*/
13+
14+
namespace Pimcore\Bundle\StudioBackendBundle\Workflow\MappedParameter;
15+
16+
/**
17+
* @internal
18+
*/
19+
final readonly class WorkflowElementsParameters
20+
{
21+
private const int MAX_PAGE_SIZE = 200;
22+
23+
public function __construct(
24+
private string $workflowName = '',
25+
private ?string $stateName = null,
26+
private ?string $elementType = null,
27+
private int $page = 1,
28+
private int $pageSize = 50,
29+
) {
30+
}
31+
32+
public function getWorkflowName(): string
33+
{
34+
return $this->workflowName;
35+
}
36+
37+
public function getStateName(): ?string
38+
{
39+
return $this->stateName;
40+
}
41+
42+
public function getElementType(): ?string
43+
{
44+
return $this->elementType;
45+
}
46+
47+
public function getPage(): int
48+
{
49+
return max(1, $this->page);
50+
}
51+
52+
public function getPageSize(): int
53+
{
54+
return max(1, min(self::MAX_PAGE_SIZE, $this->pageSize));
55+
}
56+
}

0 commit comments

Comments
 (0)