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
77 changes: 74 additions & 3 deletions config/classification_store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ services:
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\KeyGroupRelationRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\KeyGroupRelationRepository

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\StoreRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\StoreRepository


#
# Hydrators
Expand All @@ -73,3 +70,77 @@ services:

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\StoreConfigHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\StoreConfigHydrator


#
# Configuration Services
#

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\StoreServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\StoreService

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\GroupServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\GroupService

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyService

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionService


#
# Configuration Repositories
#

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\StoreRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\StoreRepository

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\GroupRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\GroupRepository

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyRepository

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollectionRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollectionRepository

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollRelationRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\CollRelationRepository

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyGroupRelationRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Repository\Configuration\KeyGroupRelationRepository


#
# Configuration Hydrators
#

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\StoreHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\StoreHydrator

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\GroupHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\GroupHydrator

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyHydrator

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionHydrator

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionRelationHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\CollectionRelationHydrator

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyGroupRelationHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\Configuration\KeyGroupRelationHydrator


#
# Configuration Relation Services
#

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionRelationServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionRelationService

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyGroupRelationServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\KeyGroupRelationService
8 changes: 8 additions & 0 deletions doc/05_Additional_Custom_Attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ final class AssetEvent extends AbstractPreResponseEvent
- `pre_response.class_field_by_type`
- `pre_response.classification_store.collection`
- `pre_response.classification_store.config_collection`
- `pre_response.classification_store.configuration.collection`
- `pre_response.classification_store.configuration.collection_relation`
- `pre_response.classification_store.configuration.get_page`
- `pre_response.classification_store.configuration.group`
- `pre_response.classification_store.configuration.key`
- `pre_response.classification_store.configuration.key_group_relation`
- `pre_response.classification_store.configuration.store`
- `pre_response.classification_store.configuration.store_tree_node`
- `pre_response.classification_store.group`
- `pre_response.classification_store.group_layout`
- `pre_response.classification_store.key_group_relation`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?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\ClassificationStore\Controller\Configuration\Collection;

use OpenApi\Attributes\Post;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Configuration\CollectionDetail;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
use Pimcore\Bundle\StudioBackendBundle\Filter\Attribute\Request\CollectionRequestBody;
use Pimcore\Bundle\StudioBackendBundle\MappedParameter\CollectionFilterParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IntParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\GenericCollection;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\Content\CollectionJson;
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\Util\Constant\UserPermissions;
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class CollectionController extends AbstractApiController
{
use PaginatedResponseTrait;

private const string ROUTE = '/classification-store/configuration/stores/{storeId}/collections';

public function __construct(
SerializerInterface $serializer,
private readonly CollectionServiceInterface $collectionService,
) {
parent::__construct($serializer);
}

Check notice on line 52 in src/ClassificationStore/Controller/Configuration/Collection/CollectionController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/ClassificationStore/Controller/Configuration/Collection/CollectionController.php#L52

Expected 1 blank line before closing function brace; 0 found

/**
* @throws InvalidArgumentException
*/
#[Route(self::ROUTE, name: 'pimcore_studio_api_cs_configuration_collection', methods: ['POST'])]
#[IsGranted(UserPermissions::CLASSIFICATION_STORE->value)]
#[Post(
path: self::PREFIX . self::ROUTE,
operationId: 'classification_store_configuration_collection_collection',
description: 'classification_store_configuration_collection_collection_description',
summary: 'classification_store_configuration_collection_collection_summary',
tags: [Tags::ClassificationStore->value]
)]
#[IntParameter(name: 'storeId', example: 1, description: 'ID of the store to list collections for')]
#[CollectionRequestBody(
columnFiltersExample: '[{"type":"search","filterValue":"my-collection"}]',
sortFilterExample: '{"key":"name","direction":"ASC"}'
)]
#[SuccessResponse(
description: 'classification_store_configuration_collection_collection_success_response',
content: new CollectionJson(new GenericCollection(CollectionDetail::class))
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
])]
public function getCollections(
int $storeId,
#[MapRequestPayload] CollectionFilterParameter $parameters,
): JsonResponse {
$collection = $this->collectionService->listCollections($parameters, $storeId);

return $this->getPaginatedCollection(
$this->serializer,
$collection->getItems(),
$collection->getTotalItems()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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\ClassificationStore\Controller\Configuration\Collection;

use OpenApi\Attributes\JsonContent;
use OpenApi\Attributes\Post;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Configuration\CollectionCreate;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Configuration\CollectionDetail;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ElementSavingFailedException;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Request\ReferenceRequestBody;
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\Util\Constant\UserPermissions;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class CreateController extends AbstractApiController
{
private const string ROUTE = '/classification-store/configuration/collections/add';

public function __construct(
SerializerInterface $serializer,
private readonly CollectionServiceInterface $collectionService,
) {
parent::__construct($serializer);
}

/**
* @throws InvalidArgumentException
* @throws ElementSavingFailedException
*/
#[Route(
self::ROUTE,
name: 'pimcore_studio_api_cs_configuration_collection_create',
methods: ['POST'],
priority: 10
)]
#[IsGranted(UserPermissions::CLASSIFICATION_STORE->value)]
#[Post(
path: self::PREFIX . self::ROUTE,
operationId: 'classification_store_configuration_collection_create',
description: 'classification_store_configuration_collection_create_description',
summary: 'classification_store_configuration_collection_create_summary',
tags: [Tags::ClassificationStore->value]
)]
#[ReferenceRequestBody(CollectionCreate::class)]
#[SuccessResponse(
description: 'classification_store_configuration_collection_create_success_response',
content: new JsonContent(ref: CollectionDetail::class)
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::INTERNAL_SERVER_ERROR,
])]
public function createCollection(
#[MapRequestPayload] CollectionCreate $parameters
): JsonResponse {
return $this->jsonResponse($this->collectionService->createCollection($parameters));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?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\ClassificationStore\Controller\Configuration\Collection;

use OpenApi\Attributes\Delete;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\Configuration\CollectionServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter;
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\Util\Constant\UserPermissions;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

/**
* @internal
*/
final class DeleteController extends AbstractApiController
{
private const string ROUTE = '/classification-store/configuration/collections/{id}';

public function __construct(

Check notice on line 38 in src/ClassificationStore/Controller/Configuration/Collection/DeleteController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/ClassificationStore/Controller/Configuration/Collection/DeleteController.php#L38

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

Check notice on line 43 in src/ClassificationStore/Controller/Configuration/Collection/DeleteController.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/ClassificationStore/Controller/Configuration/Collection/DeleteController.php#L43

Expected 2 blank lines after function; 1 found

/**
* @throws NotFoundException
*/
#[Route(self::ROUTE, name: 'pimcore_studio_api_cs_configuration_collection_delete', methods: ['DELETE'])]
#[IsGranted(UserPermissions::CLASSIFICATION_STORE->value)]
#[Delete(
path: self::PREFIX . self::ROUTE,
operationId: 'classification_store_configuration_collection_delete',
description: 'classification_store_configuration_collection_delete_description',
summary: 'classification_store_configuration_collection_delete_summary',
tags: [Tags::ClassificationStore->value]
)]
#[IdParameter(type: 'collection configuration')]
#[SuccessResponse(
description: 'classification_store_configuration_collection_delete_success_response',
)]
#[DefaultResponses([
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function deleteCollection(int $id): Response
{
$this->collectionService->deleteCollection($id);

return new Response();
}
}
Loading
Loading