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
8 changes: 7 additions & 1 deletion config/classification_store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ services:
Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\KeyGroupRelationServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\KeyGroupRelationService

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\KeyGroupLayoutServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\KeyGroupLayoutService

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\SearchHelperServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\SearchHelperService

Expand Down Expand Up @@ -57,4 +60,7 @@ services:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\GroupHydrator

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

Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\GroupLayoutHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator\GroupLayoutHydrator
105 changes: 105 additions & 0 deletions src/ClassificationStore/Controller/GetLayoutByCollectionController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Controller;

use Exception;
use OpenApi\Attributes\Get;
use OpenApi\Attributes\JsonContent;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\MappedParameter\LayoutParameter;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\CollectionLayout;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\CollectionServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter as PathIdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\IdParameter as QueryIdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\TextFieldParameter;
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\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

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

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

/**
* @throws Exception
* @throws NotFoundException
*/
#[Route(
path: '/classification-store/layout-by-collection/{collectionId}',
name: 'pimcore_studio_api_classification_store_get_layout_by_collection',
methods: ['GET']
)]
#[IsGranted(UserPermissions::DATA_OBJECTS->value)]
#[Get(
path: self::PREFIX . '/classification-store/layout-by-collection/{collectionId}',
operationId: 'classification_store_get_layout_by_collection',
description: 'classification_store_get_layout_by_collection_description',
summary: 'classification_store_get_layout_by_collection_summary',
tags: [Tags::ClassificationStore->value]
)]
#[SuccessResponse(
description: 'classification_store_get_layout_by_collection_response',
content: new JsonContent(ref: CollectionLayout::class, type: 'object')
)]
#[QueryIdParameter(
description: 'object ID',
namePrefix: 'object',
required: false
)]
#[PathIdParameter(
type: 'Collection ID',
name: 'collectionId',
)]
#[TextFieldParameter(
name: 'fieldName',
description: 'Field Name',
required: true,
example: 'technicalAttributes'
)]
#[DefaultResponses([
HttpResponseCodes::FORBIDDEN,
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function getLayoutByCollection(
#[MapQueryString] LayoutParameter $layoutParameter,
int $collectionId,
): JsonResponse {
return $this->jsonResponse(
$this->collectionService->getLayoutDefinition($collectionId, $layoutParameter)
);
}
}
105 changes: 105 additions & 0 deletions src/ClassificationStore/Controller/GetLayoutByGroupController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Controller;

use Exception;
use OpenApi\Attributes\Get;
use OpenApi\Attributes\JsonContent;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\MappedParameter\LayoutParameter;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\GroupLayout;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Service\GroupServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Path\IdParameter as PathIdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\IdParameter as QueryIdParameter;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Parameter\Query\TextFieldParameter;
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\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\Component\Serializer\SerializerInterface;

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

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

/**
* @throws Exception
* @throws NotFoundException
*/
#[Route(
path: '/classification-store/layout-by-group/{groupId}',
name: 'pimcore_studio_api_classification_store_get_layout_by_group',
methods: ['GET']
)]
#[IsGranted(UserPermissions::DATA_OBJECTS->value)]
#[Get(
path: self::PREFIX . '/classification-store/layout-by-group/{groupId}',
operationId: 'classification_store_get_layout_by_group',
description: 'classification_store_get_layout_by_group_description',
summary: 'classification_store_get_layout_by_group_summary',
tags: [Tags::ClassificationStore->value]
)]
#[SuccessResponse(
description: 'classification_store_get_layout_by_group_response',
content: new JsonContent(ref: GroupLayout::class, type: 'object')
)]
#[QueryIdParameter(
description: 'object ID',
namePrefix: 'object',
required: false
)]
#[PathIdParameter(
type: 'Group ID',
name: 'groupId',
)]
#[TextFieldParameter(
name: 'fieldName',
description: 'Field Name',
required: true,
example: 'technicalAttributes'
)]
#[DefaultResponses([
HttpResponseCodes::FORBIDDEN,
HttpResponseCodes::UNAUTHORIZED,
HttpResponseCodes::NOT_FOUND,
])]
public function getLayoutByGroup(
#[MapQueryString] LayoutParameter $layoutParameter,
int $groupId,
): JsonResponse {
return $this->jsonResponse(
$this->groupService->getLayoutDefinition($groupId, $layoutParameter)
);
}
}
3 changes: 0 additions & 3 deletions src/ClassificationStore/Event/CollectionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Collection;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;

/**
* @internal
*/
final class CollectionEvent extends AbstractPreResponseEvent
{
public const EVENT_NAME = 'pre_response.classification_store.collection';
Expand Down
3 changes: 0 additions & 3 deletions src/ClassificationStore/Event/GroupEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\Group;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;

/**
* @internal
*/
final class GroupEvent extends AbstractPreResponseEvent
{
public const EVENT_NAME = 'pre_response.classification_store.group';
Expand Down
39 changes: 39 additions & 0 deletions src/ClassificationStore/Event/GroupLayoutEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Event;

use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\GroupLayout;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;

final class GroupLayoutEvent extends AbstractPreResponseEvent
{
public const EVENT_NAME = 'pre_response.classification_store.group_layout';

public function __construct(
private readonly GroupLayout $groupLayout
) {
parent::__construct($groupLayout);
}

/**
* Use this to get additional infos out of the response object
*/
public function getGroupLayout(): GroupLayout
{
return $this->groupLayout;
}
}
3 changes: 0 additions & 3 deletions src/ClassificationStore/Event/KeyGroupRelationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\KeyGroupRelation;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;

/**
* @internal
*/
final class KeyGroupRelationEvent extends AbstractPreResponseEvent
{
public const EVENT_NAME = 'pre_response.classification_store.key_group_relation';
Expand Down
36 changes: 36 additions & 0 deletions src/ClassificationStore/Hydrator/GroupLayoutHydrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator;

use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\GroupLayout;
use Pimcore\Model\DataObject\Classificationstore\GroupConfig;

/**
* @internal
*/
final class GroupLayoutHydrator implements GroupLayoutHydratorInterface
{
public function hydrate(array $keys, GroupConfig $group): GroupLayout
{
return new GroupLayout(
id: $group->getId(),
name: $group->getName(),
description: $group->getDescription(),
keys: $keys,
);
}
}
32 changes: 32 additions & 0 deletions src/ClassificationStore/Hydrator/GroupLayoutHydratorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Hydrator;

use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\GroupLayout;
use Pimcore\Bundle\StudioBackendBundle\ClassificationStore\Schema\KeyLayout;
use Pimcore\Model\DataObject\Classificationstore\GroupConfig;

/**
* @internal
*/
interface GroupLayoutHydratorInterface
{
/**
* @param array<int, KeyLayout> $keys
*/
public function hydrate(array $keys, GroupConfig $group): GroupLayout;
}
Loading
Loading