Skip to content

Commit

Permalink
Merge branch '1.x' into 597-data-object-editor-field-collections-with…
Browse files Browse the repository at this point in the history
…-block-and-localized-fields-not-working
  • Loading branch information
martineiber committed Dec 3, 2024
2 parents 0237225 + 6f557dd commit a653eef
Show file tree
Hide file tree
Showing 40 changed files with 966 additions and 68 deletions.
15 changes: 1 addition & 14 deletions config/assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ services:
Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomSettingsHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomSettingsHydrator

Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomMetadataHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Hydrator\CustomMetadataHydrator

# Encoder
Pimcore\Bundle\StudioBackendBundle\Asset\Encoder\TextEncoderInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Encoder\TextEncoder
Expand All @@ -29,8 +26,7 @@ services:
Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomSettingsServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomSettingsService

Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataService


Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\TextServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\TextService
Expand Down Expand Up @@ -73,21 +69,12 @@ services:
Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\ImageAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\CustomMetadataAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\CustomSettingsAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

Pimcore\Bundle\StudioBackendBundle\Asset\Updater\Adapter\DataAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

#
# Patcher
#

Pimcore\Bundle\StudioBackendBundle\Asset\Patcher\Adapter\MetadataAdapter:
tags: [ 'pimcore.studio_backend.patch_adapter' ]

#
# Handler
Expand Down
8 changes: 7 additions & 1 deletion config/class.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ services:
Pimcore\Bundle\StudioBackendBundle\Class\Service\FieldCollection\LayoutDefinitionServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Class\Service\FieldCollection\LayoutDefinitionService

Pimcore\Bundle\StudioBackendBundle\Class\Service\ObjectBrick\LayoutDefinitionServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Class\Service\ObjectBrick\LayoutDefinitionService

Pimcore\Bundle\StudioBackendBundle\Class\Repository\QuantityValueRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\Class\Repository\QuantityValueRepository

Expand All @@ -27,4 +30,7 @@ services:
# Hydrators
#
Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection\LayoutDefinitionHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection\LayoutDefinitionHydrator
class: Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection\LayoutDefinitionHydrator

Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\ObjectBrick\LayoutDefinitionHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\ObjectBrick\LayoutDefinitionHydrator
27 changes: 24 additions & 3 deletions config/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ services:
autoconfigure: true
public: false

#
# Repository
#

# controllers are imported separately to make sure they're public
# and have a tag that allows actions to type-hint services
Pimcore\Bundle\StudioBackendBundle\Metadata\Controller\:
resource: '../src/Metadata/Controller'
public: true
tags: [ 'controller.service_arguments' ]

# Service
Pimcore\Bundle\StudioBackendBundle\Metadata\Service\MetadataServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Metadata\Service\MetadataService


# Hydrator
Pimcore\Bundle\StudioBackendBundle\Metadata\Hydrator\MetadataHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Metadata\Hydrator\MetadataHydrator

# Repository
Pimcore\Bundle\StudioBackendBundle\Metadata\Repository\MetadataRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\Metadata\Repository\MetadataRepository

Pimcore\Bundle\StudioBackendBundle\Metadata\Updater\Adapter\CustomMetadataAdapter:
tags: [ 'pimcore.studio_backend.update_adapter' ]

# Patcher
Pimcore\Bundle\StudioBackendBundle\Metadata\Patcher\Adapter\CustomMetadataAdapter:
tags: [ 'pimcore.studio_backend.patch_adapter' ]
2 changes: 1 addition & 1 deletion src/Class/Controller/FieldCollection/LayoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Exception;
use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Class\Schema\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Class\Schema\FieldCollection\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Class\Service\FieldCollection\LayoutDefinitionServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
Expand Down
82 changes: 82 additions & 0 deletions src/Class/Controller/ObjectBrick/LayoutController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?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\Class\Controller\ObjectBrick;

use Exception;
use OpenApi\Attributes\Get;
use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ObjectBrick\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Class\Service\ObjectBrick\LayoutDefinitionServiceInterface;
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\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\Trait\PaginatedResponseTrait;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Serializer\SerializerInterface;
use function count;

final class LayoutController extends AbstractApiController
{
use PaginatedResponseTrait;

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

/**
* @throws Exception|NotFoundException
*/
#[Route(
'/class/object-brick/{objectId}/object/layout',
name: 'pimcore_studio_api_class_object_brick_object_layout',
methods: ['GET']
)]
#[Get(
path: self::PREFIX . '/class/object-brick/{objectId}/object/layout',
operationId: 'class_object_brick_object_layout',
description: 'class_object_brick_object_layout_description',
summary: 'class_object_brick_object_layout_summary',
tags: [Tags::ClassDefinition->value],
)]
#[IdParameter(name: 'objectId', required: true)]
#[SuccessResponse(
description: 'class_object_brick_object_layout_success_response',
content: new CollectionJson(new GenericCollection(LayoutDefinition::class))
)]
#[DefaultResponses([
HttpResponseCodes::NOT_FOUND,
])]
public function getObjectBrickLayoutForObject(int $objectId): JsonResponse
{
$items = $this->layoutDefinitionService->getLayoutDefinitionsForObject($objectId);

return $this->getPaginatedCollection(
$this->serializer,
$items,
count($items),
);
}
}
2 changes: 1 addition & 1 deletion src/Class/Event/FieldCollection/LayoutDefinitionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\Class\Event\FieldCollection;

use Pimcore\Bundle\StudioBackendBundle\Class\Schema\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Class\Schema\FieldCollection\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;

final class LayoutDefinitionEvent extends AbstractPreResponseEvent
Expand Down
35 changes: 35 additions & 0 deletions src/Class/Event/ObjectBrick/LayoutDefinitionEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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\Class\Event\ObjectBrick;

use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ObjectBrick\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent;

final class LayoutDefinitionEvent extends AbstractPreResponseEvent
{
public const EVENT_NAME = 'pre_response.objectBrick.layout_definition';

public function __construct(private readonly LayoutDefinition $layoutDefinition)
{
parent::__construct($this->layoutDefinition);
}

public function getLayoutDefinition(): LayoutDefinition
{
return $this->layoutDefinition;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection;

use Pimcore\Bundle\StudioBackendBundle\Class\Schema\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Class\Schema\FieldCollection\LayoutDefinition;
use Pimcore\Model\DataObject\Fieldcollection\Definition as FieldCollectionDefinition;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\Class\Hydrator\FieldCollection;

use Pimcore\Bundle\StudioBackendBundle\Class\Schema\LayoutDefinition;
use Pimcore\Bundle\StudioBackendBundle\Class\Schema\FieldCollection\LayoutDefinition;
use Pimcore\Model\DataObject\Fieldcollection\Definition as FieldCollectionDefinition;

/**
Expand Down
45 changes: 45 additions & 0 deletions src/Class/Hydrator/ObjectBrick/LayoutDefinitionHydrator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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\Class\Hydrator\ObjectBrick;

use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ObjectBrick\LayoutDefinition;
use Pimcore\Model\DataObject\Objectbrick\Definition as ObjectBrickDefinition;

/**
* @internal
*/
final class LayoutDefinitionHydrator implements LayoutDefinitionHydratorInterface
{
public function hydrate(ObjectBrickDefinition $data): LayoutDefinition
{
$layout = $data->getLayoutDefinitions();

return new LayoutDefinition(
$data->getKey(),
$layout->getDatatype(),
$layout->getName(),
$layout->getType(),
$layout->getRegion(),
$layout->getTitle(),
$layout->getWidth(),
$layout->getHeight(),
$layout->getCollapsible(),
$layout->getCollapsed(),
$layout->getChildren(),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?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\Class\Hydrator\ObjectBrick;

use Pimcore\Bundle\StudioBackendBundle\Class\Schema\ObjectBrick\LayoutDefinition;
use Pimcore\Model\DataObject\Objectbrick\Definition as ObjectBrickDefinition;

/**
* @internal
*/
interface LayoutDefinitionHydratorInterface
{
public function hydrate(ObjectBrickDefinition $data): LayoutDefinition;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\StudioBackendBundle\Class\Schema;
namespace Pimcore\Bundle\StudioBackendBundle\Class\Schema\FieldCollection;

use OpenApi\Attributes\Items;
use OpenApi\Attributes\Property;
Expand All @@ -26,6 +26,7 @@
* @internal
*/
#[Schema(
schema: 'FieldCollectionLayoutDefinition',
title: 'Field Collection Layout Definition',
required: [
'key',
Expand Down
Loading

0 comments on commit a653eef

Please sign in to comment.