Skip to content

Commit 47b7d89

Browse files
authored
[Classification Store]: Add config endpoints (#1686)
* add endpoints for classification store config * Apply php-cs-fixer changes * fix: sonar
1 parent b473c33 commit 47b7d89

101 files changed

Lines changed: 6110 additions & 160 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/classification_store.yaml

Lines changed: 74 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ services:
5151
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\KeyGroupRelationRepositoryInterface:
5252
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\KeyGroupRelationRepository
5353

54-
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\StoreRepositoryInterface:
55-
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\StoreRepository
56-
5754

5855
#
5956
# Hydrators
@@ -73,3 +70,77 @@ services:
7370

7471
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\StoreConfigHydratorInterface:
7572
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\StoreConfigHydrator
73+
74+
75+
#
76+
# Configuration Services
77+
#
78+
79+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\StoreServiceInterface:
80+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\StoreService
81+
82+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\GroupServiceInterface:
83+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\GroupService
84+
85+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyServiceInterface:
86+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyService
87+
88+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface:
89+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionService
90+
91+
92+
#
93+
# Configuration Repositories
94+
#
95+
96+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\StoreRepositoryInterface:
97+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\StoreRepository
98+
99+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\GroupRepositoryInterface:
100+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\GroupRepository
101+
102+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyRepositoryInterface:
103+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyRepository
104+
105+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollectionRepositoryInterface:
106+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollectionRepository
107+
108+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollRelationRepositoryInterface:
109+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollRelationRepository
110+
111+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyGroupRelationRepositoryInterface:
112+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyGroupRelationRepository
113+
114+
115+
#
116+
# Configuration Hydrators
117+
#
118+
119+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\StoreHydratorInterface:
120+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\StoreHydrator
121+
122+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\GroupHydratorInterface:
123+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\GroupHydrator
124+
125+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyHydratorInterface:
126+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyHydrator
127+
128+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionHydratorInterface:
129+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionHydrator
130+
131+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionRelationHydratorInterface:
132+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionRelationHydrator
133+
134+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyGroupRelationHydratorInterface:
135+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyGroupRelationHydrator
136+
137+
138+
#
139+
# Configuration Relation Services
140+
#
141+
142+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionRelationServiceInterface:
143+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionRelationService
144+
145+
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyGroupRelationServiceInterface:
146+
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyGroupRelationService

doc/05_Additional_Custom_Attributes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ final class AssetEvent extends AbstractPreResponseEvent
9191
- `pre_response.class_field_by_type`
9292
- `pre_response.classification_store.collection`
9393
- `pre_response.classification_store.config_collection`
94+
- `pre_response.classification_store.configuration.collection`
95+
- `pre_response.classification_store.configuration.collection_relation`
96+
- `pre_response.classification_store.configuration.get_page`
97+
- `pre_response.classification_store.configuration.group`
98+
- `pre_response.classification_store.configuration.key`
99+
- `pre_response.classification_store.configuration.key_group_relation`
100+
- `pre_response.classification_store.configuration.store`
101+
- `pre_response.classification_store.configuration.store_tree_node`
94102
- `pre_response.classification_store.group`
95103
- `pre_response.classification_store.group_layout`
96104
- `pre_response.classification_store.key_group_relation`
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\ClassificationStore\Controller\Configuration\Collection;
15+
16+
use OpenApi\Attributes\Post;
17+
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Configuration\CollectionDetail;
18+
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface;
19+
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
20+
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
21+
use Pimcore\Bundle\StudioBackendBundle\Filter\Attribute\Request\CollectionRequestBody;
22+
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionFilterParameter;
23+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IntParameter;
24+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\GenericCollection;
25+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\CollectionJson;
26+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
27+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
28+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
29+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
30+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
31+
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait;
32+
use Symfony\Component\HttpFoundation\JsonResponse;
33+
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
34+
use Symfony\Component\Routing\Attribute\Route;
35+
use Symfony\Component\Security\Http\Attribute\IsGranted;
36+
use Symfony\Component\Serializer\SerializerInterface;
37+
38+
/**
39+
* @internal
40+
*/
41+
final class CollectionController extends AbstractApiController
42+
{
43+
use PaginatedResponseTrait;
44+
45+
private const string ROUTE = '/classification-store/configuration/stores/{storeId}/collections';
46+
47+
public function __construct(
48+
SerializerInterface $serializer,
49+
private readonly CollectionServiceInterface $collectionService,
50+
) {
51+
parent::__construct($serializer);
52+
}
53+
54+
/**
55+
* @throws InvalidArgumentException
56+
*/
57+
#[Route(self::ROUTE, name: 'pimcore_studio_api_cs_configuration_collection', methods: ['POST'])]
58+
#[IsGranted(UserPermissions::CLASSIFICATION_STORE->value)]
59+
#[Post(
60+
path: self::PREFIX . self::ROUTE,
61+
operationId: 'classification_store_configuration_collection_collection',
62+
description: 'classification_store_configuration_collection_collection_description',
63+
summary: 'classification_store_configuration_collection_collection_summary',
64+
tags: [Tags::ClassificationStore->value]
65+
)]
66+
#[IntParameter(name: 'storeId', example: 1, description: 'ID of the store to list collections for')]
67+
#[CollectionRequestBody(
68+
columnFiltersExample: '[{"type":"search","filterValue":"my-collection"}]',
69+
sortFilterExample: '{"key":"name","direction":"ASC"}'
70+
)]
71+
#[SuccessResponse(
72+
description: 'classification_store_configuration_collection_collection_success_response',
73+
content: new CollectionJson(new GenericCollection(CollectionDetail::class))
74+
)]
75+
#[DefaultResponses([
76+
HttpResponseCodes::UNAUTHORIZED,
77+
])]
78+
public function getCollections(
79+
int $storeId,
80+
#[MapRequestPayload] CollectionFilterParameter $parameters,
81+
): JsonResponse {
82+
$collection = $this->collectionService->listCollections($parameters, $storeId);
83+
84+
return $this->getPaginatedCollection(
85+
$this->serializer,
86+
$collection->getItems(),
87+
$collection->getTotalItems()
88+
);
89+
}
90+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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\ClassificationStore\Controller\Configuration\Collection;
15+
16+
use OpenApi\Attributes\JsonContent;
17+
use OpenApi\Attributes\Post;
18+
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Configuration\CollectionCreate;
19+
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Configuration\CollectionDetail;
20+
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface;
21+
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
22+
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ElementSavingFailedException;
23+
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
24+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Request\ReferenceRequestBody;
25+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
26+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
27+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
28+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
29+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
30+
use Symfony\Component\HttpFoundation\JsonResponse;
31+
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
32+
use Symfony\Component\Routing\Attribute\Route;
33+
use Symfony\Component\Security\Http\Attribute\IsGranted;
34+
use Symfony\Component\Serializer\SerializerInterface;
35+
36+
/**
37+
* @internal
38+
*/
39+
final class CreateController extends AbstractApiController
40+
{
41+
private const string ROUTE = '/classification-store/configuration/collections/add';
42+
43+
public function __construct(
44+
SerializerInterface $serializer,
45+
private readonly CollectionServiceInterface $collectionService,
46+
) {
47+
parent::__construct($serializer);
48+
}
49+
50+
/**
51+
* @throws InvalidArgumentException
52+
* @throws ElementSavingFailedException
53+
*/
54+
#[Route(
55+
self::ROUTE,
56+
name: 'pimcore_studio_api_cs_configuration_collection_create',
57+
methods: ['POST'],
58+
priority: 10
59+
)]
60+
#[IsGranted(UserPermissions::CLASSIFICATION_STORE->value)]
61+
#[Post(
62+
path: self::PREFIX . self::ROUTE,
63+
operationId: 'classification_store_configuration_collection_create',
64+
description: 'classification_store_configuration_collection_create_description',
65+
summary: 'classification_store_configuration_collection_create_summary',
66+
tags: [Tags::ClassificationStore->value]
67+
)]
68+
#[ReferenceRequestBody(CollectionCreate::class)]
69+
#[SuccessResponse(
70+
description: 'classification_store_configuration_collection_create_success_response',
71+
content: new JsonContent(ref: CollectionDetail::class)
72+
)]
73+
#[DefaultResponses([
74+
HttpResponseCodes::UNAUTHORIZED,
75+
HttpResponseCodes::INTERNAL_SERVER_ERROR,
76+
])]
77+
public function createCollection(
78+
#[MapRequestPayload] CollectionCreate $parameters
79+
): JsonResponse {
80+
return $this->jsonResponse($this->collectionService->createCollection($parameters));
81+
}
82+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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\ClassificationStore\Controller\Configuration\Collection;
15+
16+
use OpenApi\Attributes\Delete;
17+
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface;
18+
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
19+
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
20+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
21+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
22+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
23+
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
24+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
25+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
26+
use Symfony\Component\HttpFoundation\Response;
27+
use Symfony\Component\Routing\Attribute\Route;
28+
use Symfony\Component\Security\Http\Attribute\IsGranted;
29+
use Symfony\Component\Serializer\SerializerInterface;
30+
31+
/**
32+
* @internal
33+
*/
34+
final class DeleteController extends AbstractApiController
35+
{
36+
private const string ROUTE = '/classification-store/configuration/collections/{id}';
37+
38+
public function __construct(
39+
SerializerInterface $serializer,
40+
private readonly CollectionServiceInterface $collectionService,
41+
) {
42+
parent::__construct($serializer);
43+
}
44+
45+
/**
46+
* @throws NotFoundException
47+
*/
48+
#[Route(self::ROUTE, name: 'pimcore_studio_api_cs_configuration_collection_delete', methods: ['DELETE'])]
49+
#[IsGranted(UserPermissions::CLASSIFICATION_STORE->value)]
50+
#[Delete(
51+
path: self::PREFIX . self::ROUTE,
52+
operationId: 'classification_store_configuration_collection_delete',
53+
description: 'classification_store_configuration_collection_delete_description',
54+
summary: 'classification_store_configuration_collection_delete_summary',
55+
tags: [Tags::ClassificationStore->value]
56+
)]
57+
#[IdParameter(type: 'collection configuration')]
58+
#[SuccessResponse(
59+
description: 'classification_store_configuration_collection_delete_success_response',
60+
)]
61+
#[DefaultResponses([
62+
HttpResponseCodes::UNAUTHORIZED,
63+
HttpResponseCodes::NOT_FOUND,
64+
])]
65+
public function deleteCollection(int $id): Response
66+
{
67+
$this->collectionService->deleteCollection($id);
68+
69+
return new Response();
70+
}
71+
}

0 commit comments

Comments
 (0)