Skip to content
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
3 changes: 3 additions & 0 deletions config/element_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ services:
Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowElementsService

Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaService

# Repositories
Pimcore\Bundle\StudioBackendBundle\Workflow\Repository\WorkflowElementsRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\Workflow\Repository\WorkflowElementsRepository
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Content;

use OpenApi\Attributes\JsonContent;
use Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Property\WorkflowStringCollection;

/**
* @internal
*/
final class WorkflowStringListContent extends JsonContent
{
public function __construct()

Check notice on line 24 in src/Workflow/Attribute/Response/Content/WorkflowStringListContent.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Attribute/Response/Content/WorkflowStringListContent.php#L24

Expected 2 blank lines before function; 0 found
{
parent::__construct(
required: ['items'],
properties: [
new WorkflowStringCollection(),
],
type: 'object',
);
}

Check notice on line 33 in src/Workflow/Attribute/Response/Content/WorkflowStringListContent.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Attribute/Response/Content/WorkflowStringListContent.php#L33

Expected 1 blank line before closing function brace; 0 found

Check notice on line 33 in src/Workflow/Attribute/Response/Content/WorkflowStringListContent.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Attribute/Response/Content/WorkflowStringListContent.php#L33

Expected 2 blank lines after function; 0 found
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Property;

use OpenApi\Attributes\Items;
use OpenApi\Attributes\Property;

/**
* @internal
*/
final class WorkflowStringCollection extends Property
{
public function __construct()

Check notice on line 24 in src/Workflow/Attribute/Response/Property/WorkflowStringCollection.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Attribute/Response/Property/WorkflowStringCollection.php#L24

Expected 2 blank lines before function; 0 found
{
parent::__construct(
'items',
title: 'items',
type: 'array',
items: new Items(type: 'string'),
);
}

Check notice on line 32 in src/Workflow/Attribute/Response/Property/WorkflowStringCollection.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Attribute/Response/Property/WorkflowStringCollection.php#L32

Expected 1 blank line before closing function brace; 0 found

Check notice on line 32 in src/Workflow/Attribute/Response/Property/WorkflowStringCollection.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Attribute/Response/Property/WorkflowStringCollection.php#L32

Expected 2 blank lines after function; 0 found
}
64 changes: 64 additions & 0 deletions src/Workflow/Controller/NamesCollectionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Controller;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Content\WorkflowStringListContent;
use Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaServiceInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class NamesCollectionController extends AbstractApiController
{
private const string ROUTE = '/workflows/names';

public function __construct(

Check notice on line 35 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L35

Expected 2 blank lines before function; 1 found
SerializerInterface $serializer,
private readonly WorkflowMetaServiceInterface $workflowMetaService,
) {
parent::__construct($serializer);
}

Check notice on line 40 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L40

Expected 1 blank line before closing function brace; 0 found

Check notice on line 40 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L40

Expected 2 blank lines after function; 1 found

#[Route(path: self::ROUTE, name: 'pimcore_studio_api_workflows_names', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
#[Get(
path: self::PREFIX . self::ROUTE,
operationId: 'workflow_get_names',
description: 'workflow_get_names_description',
summary: 'workflow_get_names_summary',
tags: [Tags::Workflows->name]
)]
#[SuccessResponse(
description: 'workflow_get_names_success_response',
content: new WorkflowStringListContent()
)]
#[DefaultResponses([

Check notice on line 55 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L55

Opening parenthesis of a multi-line function call must be the last content on the line
HttpResponseCodes::UNAUTHORIZED,
])]

Check notice on line 57 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L57

Closing parenthesis of a multi-line function call must be on a line by itself
public function getNames(): JsonResponse

Check notice on line 58 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L58

Expected 2 blank lines before function; 0 found
{
return $this->jsonResponse([

Check notice on line 60 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L60

Opening parenthesis of a multi-line function call must be the last content on the line
'items' => $this->workflowMetaService->getWorkflowNames(),
]);

Check notice on line 62 in src/Workflow/Controller/NamesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/NamesCollectionController.php#L62

Closing parenthesis of a multi-line function call must be on a line by itself
}
}
69 changes: 69 additions & 0 deletions src/Workflow/Controller/PlacesCollectionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Controller;

use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\StringParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
use Pimcore\Bundle\StudioBackendBundle\Workflow\Attribute\Response\Content\WorkflowStringListContent;
use Pimcore\Bundle\StudioBackendBundle\Workflow\MappedParameter\WorkflowPlacesParameters;
use Pimcore\Bundle\StudioBackendBundle\Workflow\Service\WorkflowMetaServiceInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class PlacesCollectionController extends AbstractApiController
{
private const string ROUTE = '/workflows/places';

public function __construct(

Check notice on line 38 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L38

Expected 2 blank lines before function; 1 found
SerializerInterface $serializer,
private readonly WorkflowMetaServiceInterface $workflowMetaService,
) {
parent::__construct($serializer);
}

Check notice on line 43 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L43

Expected 1 blank line before closing function brace; 0 found

Check notice on line 43 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L43

Expected 2 blank lines after function; 1 found

#[Route(path: self::ROUTE, name: 'pimcore_studio_api_workflows_places', methods: ['GET'])]
//#[IsGranted('STUDIO_API')]
#[Get(
path: self::PREFIX . self::ROUTE,
operationId: 'workflow_get_places',
description: 'workflow_get_places_description',
summary: 'workflow_get_places_summary',
tags: [Tags::Workflows->name]
)]
#[StringParameter('workflowName', 'product_workflow', 'workflow_get_places_workflow_name')]
#[SuccessResponse(
description: 'workflow_get_places_success_response',
content: new WorkflowStringListContent()
)]
#[DefaultResponses([

Check notice on line 59 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L59

Opening parenthesis of a multi-line function call must be the last content on the line
HttpResponseCodes::UNAUTHORIZED,
])]

Check notice on line 61 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L61

Closing parenthesis of a multi-line function call must be on a line by itself
public function getPlaces(

Check notice on line 62 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L62

Expected 2 blank lines before function; 0 found
#[MapQueryString] WorkflowPlacesParameters $parameters = new WorkflowPlacesParameters()

Check notice on line 63 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L63

Incorrect spacing between argument "$parameters" and equals sign; expected 0 but found 1
): JsonResponse {
return $this->jsonResponse([

Check notice on line 65 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L65

Opening parenthesis of a multi-line function call must be the last content on the line
'items' => $this->workflowMetaService->getPlaces($parameters->getWorkflowName()),
]);

Check notice on line 67 in src/Workflow/Controller/PlacesCollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Controller/PlacesCollectionController.php#L67

Closing parenthesis of a multi-line function call must be on a line by itself
}
}
30 changes: 30 additions & 0 deletions src/Workflow/MappedParameter/WorkflowPlacesParameters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\MappedParameter;

/**
* @internal
*/
final readonly class WorkflowPlacesParameters
{
public function __construct(

Check notice on line 21 in src/Workflow/MappedParameter/WorkflowPlacesParameters.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/MappedParameter/WorkflowPlacesParameters.php#L21

Expected 2 blank lines before function; 0 found
private string $workflowName = '',

Check notice on line 22 in src/Workflow/MappedParameter/WorkflowPlacesParameters.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/MappedParameter/WorkflowPlacesParameters.php#L22

Incorrect spacing between argument "$workflowName" and equals sign; expected 0 but found 1
) {
}

Check notice on line 24 in src/Workflow/MappedParameter/WorkflowPlacesParameters.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/MappedParameter/WorkflowPlacesParameters.php#L24

Expected 1 blank line before closing function brace; 0 found

Check notice on line 24 in src/Workflow/MappedParameter/WorkflowPlacesParameters.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/MappedParameter/WorkflowPlacesParameters.php#L24

Expected 2 blank lines after function; 1 found

public function getWorkflowName(): string
{
return $this->workflowName;
}
}
54 changes: 54 additions & 0 deletions src/Workflow/Service/WorkflowMetaService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Service;

use Pimcore\Workflow\Manager;
use function array_keys;
use function in_array;

/**
* @internal
*/
final readonly class WorkflowMetaService implements WorkflowMetaServiceInterface
{
public function __construct(

Check notice on line 25 in src/Workflow/Service/WorkflowMetaService.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Service/WorkflowMetaService.php#L25

Expected 2 blank lines before function; 0 found
private Manager $workflowManager,
) {
}

Check notice on line 28 in src/Workflow/Service/WorkflowMetaService.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Service/WorkflowMetaService.php#L28

Expected 1 blank line before closing function brace; 0 found

Check notice on line 28 in src/Workflow/Service/WorkflowMetaService.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Service/WorkflowMetaService.php#L28

Expected 2 blank lines after function; 1 found

/**
* @return string[]
*/
public function getWorkflowNames(): array
{
return $this->workflowManager->getAllWorkflows();
}

/**
* @return string[]
*/
public function getPlaces(string $workflowName): array
{
if ($workflowName === '' || !in_array($workflowName, $this->workflowManager->getAllWorkflows(), true)) {
return [];
}

$workflow = $this->workflowManager->getWorkflowByName($workflowName);
if ($workflow === null) {
return [];
}

return array_keys($workflow->getDefinition()->getPlaces());
}
}
30 changes: 30 additions & 0 deletions src/Workflow/Service/WorkflowMetaServiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);

/**
* This source file is available under the terms of the
* Pimcore Open Core License (POCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com)
* @license Pimcore Open Core License (POCL)
*/

namespace Pimcore\Bundle\StudioBackendBundle\Workflow\Service;

/**
* @internal
*/
interface WorkflowMetaServiceInterface
{
/**
* @return string[]
*/
public function getWorkflowNames(): array;

Check notice on line 24 in src/Workflow/Service/WorkflowMetaServiceInterface.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Service/WorkflowMetaServiceInterface.php#L24

Expected 2 blank lines before function; 0 found

/**
* @return string[]
*/
public function getPlaces(string $workflowName): array;

Check notice on line 29 in src/Workflow/Service/WorkflowMetaServiceInterface.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Workflow/Service/WorkflowMetaServiceInterface.php#L29

Expected 2 blank lines after function; 0 found
}
Loading
Loading