Skip to content

Commit

Permalink
Merge branch '1.x' into 586-object-brick-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
martineiber committed Dec 2, 2024
2 parents da3d3f0 + 1071eff commit 211cf2e
Show file tree
Hide file tree
Showing 90 changed files with 1,374 additions and 150 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
33 changes: 31 additions & 2 deletions config/documents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@ services:
autoconfigure: true
public: false

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

#
# Services
#

Pimcore\Bundle\StudioBackendBundle\Document\Service\DocumentServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Document\Service\DocumentService
class: Pimcore\Bundle\StudioBackendBundle\Document\Service\DocumentService

Pimcore\Bundle\StudioBackendBundle\Document\Service\SiteServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Document\Service\SiteService


#
# Repositories
#

Pimcore\Bundle\StudioBackendBundle\Document\Repository\SiteRepositoryInterface:
class: Pimcore\Bundle\StudioBackendBundle\Document\Repository\SiteRepository


#
# Hydrators
#

Pimcore\Bundle\StudioBackendBundle\Document\Hydrator\SiteHydratorInterface:
class: Pimcore\Bundle\StudioBackendBundle\Document\Hydrator\SiteHydrator
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' ]
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __construct(
operationId: 'asset_video_image_thumbnail_stream',
description: 'asset_video_image_thumbnail_stream_description',
summary: 'asset_video_image_thumbnail_stream_summary',
tags: [Tags::Assets->name]
tags: [Tags::Assets->value]
)]
#[IdParameter(type: 'video')]
#[WidthParameter('Width of the video image thumbnail', 265)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter;

use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ConcreteObjectResolverInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Model\DataObject\ClassDefinition\Data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Exception;
use Pimcore\Bundle\StaticResolverBundle\Models\Element\ServiceResolverInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\ElementProviderTrait;
Expand Down
41 changes: 34 additions & 7 deletions src/DataObject/Data/Adapter/BlockAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

use Exception;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\DataNormalizerInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Util\Trait\ValidateFieldTypeTrait;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidDataTypeException;
use Pimcore\Model\DataObject\ClassDefinition\Data;
use Pimcore\Model\DataObject\ClassDefinition\Data\Block;
Expand All @@ -38,6 +39,8 @@
#[AutoconfigureTag(DataAdapterLoaderInterface::ADAPTER_TAG)]
final readonly class BlockAdapter implements SetterDataInterface, DataNormalizerInterface
{
use ValidateFieldTypeTrait;

public function __construct(
private DataAdapterServiceInterface $dataAdapterService,
private DataServiceInterface $dataService
Expand Down Expand Up @@ -82,7 +85,7 @@ public function normalize(
/** @var BlockElement $fieldValue */
foreach ($block as $key => $fieldValue) {
$blockDefinition = $fieldDefinitions[$key];
$resultItems[$key] = $this->dataService->getNormalizedValue(
$resultItem[$key] = $this->dataService->getNormalizedValue(
$fieldValue->getData(),
$blockDefinition,
);
Expand Down Expand Up @@ -148,13 +151,24 @@ private function processBlockElement(
$fieldContextData = $this->createFieldContextData($element, $fieldDefinition, $contextData);

foreach ($fieldDefinitions as $elementName => $fd) {
$resultElement[$elementName] = $this->createBlockElement(
$adapter = $this->dataAdapterService->tryDataAdapter($fd->getFieldType());
if (!$adapter) {
continue;
}

$value = $this->createBlockElement(
$adapter,
$element,
$fd,
$elementName,
$blockElement,
$fieldContextData
);
if (!$value) {
continue;
}

$resultElement[$elementName] = $value;
}

return $resultElement;
Expand All @@ -164,24 +178,37 @@ private function processBlockElement(
* @throws Exception
*/
private function createBlockElement(
SetterDataInterface $adapter,
Concrete $element,
Data $fieldDefinition,
string $elementName,
?array $blockElement,
?FieldContextData $fieldContextData = null
): BlockElement {
): ?BlockElement {
$elementType = $fieldDefinition->getFieldtype();
$elementData = $blockElement[$elementName] ?? null;

$adapter = $this->dataAdapterService->getDataAdapter($elementType);
$blockData = $adapter->getDataForSetter(
$data = $adapter->getDataForSetter(
$element,
$fieldDefinition,
$elementName,
[$elementName => $elementData],
$fieldContextData
);
if (!$this->validateEncryptedField($fieldDefinition, $data)) {
return null;
}

return new BlockElement($elementName, $elementType, $blockData);
return new BlockElement(
$elementName,
$elementType,
$adapter->getDataForSetter(
$element,
$fieldDefinition,
$elementName,
[$elementName => $elementData],
$fieldContextData
)
);
}
}
2 changes: 1 addition & 1 deletion src/DataObject/Data/Adapter/BooleanAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter;

use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Model\DataObject\ClassDefinition\Data;
Expand Down
2 changes: 1 addition & 1 deletion src/DataObject/Data/Adapter/CalculatedValueAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter;

use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Model\DataObject\ClassDefinition\Data;
Expand Down
2 changes: 1 addition & 1 deletion src/DataObject/Data/Adapter/CheckboxAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter;

use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Util\Trait\DefaultSetterValueTrait;
Expand Down
14 changes: 12 additions & 2 deletions src/DataObject/Data/Adapter/ClassificationStoreAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassificationStore\GroupConfigResolverInterface;
use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassificationStore\ServiceResolverInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\DataNormalizerInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Util\Trait\ValidateFieldTypeTrait;
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\DatabaseException;
use Pimcore\Model\DataObject\ClassDefinition\Data;
use Pimcore\Model\DataObject\ClassDefinition\Data\Classificationstore as ClassificationstoreDefinition;
Expand All @@ -47,6 +48,8 @@
#[AutoconfigureTag(DataAdapterLoaderInterface::ADAPTER_TAG)]
final readonly class ClassificationStoreAdapter implements SetterDataInterface, DataNormalizerInterface
{
use ValidateFieldTypeTrait;

public function __construct(
private DefinitionCacheResolverInterface $definitionCacheResolver,
private DataAdapterServiceInterface $dataAdapterService,
Expand Down Expand Up @@ -182,13 +185,20 @@ private function processGroupKeys(
continue;
}

$adapter = $this->dataAdapterService->getDataAdapter($fieldDefinition->getFieldType());
$adapter = $this->dataAdapterService->tryDataAdapter($fieldDefinition->getFieldType());
if ($adapter === null) {
continue;
}

$setterData = $adapter->getDataForSetter(
$element,
$fieldDefinition,
$fieldDefinition->getName(),
[$fieldDefinition->getName() => $value]
);
if (!$this->validateEncryptedField($fieldDefinition, $setterData)) {
continue;
}

$container->setLocalizedKeyValue($groupId, $keyId, $setterData, $language);
}
Expand Down
21 changes: 19 additions & 2 deletions src/DataObject/Data/Adapter/ConsentAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter;

use Exception;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\DataNormalizerInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\ConsentData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\DataObject\Consent\Service;
Expand All @@ -30,7 +32,7 @@
* @internal
*/
#[AutoconfigureTag(DataAdapterLoaderInterface::ADAPTER_TAG)]
final readonly class ConsentAdapter implements SetterDataInterface
final readonly class ConsentAdapter implements SetterDataInterface, DataNormalizerInterface
{
public function __construct(
private Service $service
Expand Down Expand Up @@ -76,4 +78,19 @@ public function getDataForSetter(

return new Consent($value, $noteId);
}

public function normalize(
mixed $value,
Data $fieldDefinition
): ?ConsentData {
if (!$value instanceof Consent) {
return null;
}

return new ConsentData(
$value->getConsent(),
$value->getNoteId(),
$value->getSummaryString(),
);
}
}
2 changes: 1 addition & 1 deletion src/DataObject/Data/Adapter/DateAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter;

use Carbon\Carbon;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Model\DataObject\ClassDefinition\Data;
Expand Down
2 changes: 1 addition & 1 deletion src/DataObject/Data/Adapter/DateRangeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

use Carbon\Carbon;
use Carbon\CarbonPeriod;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Model\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Model\DataObject\ClassDefinition\Data;
Expand Down
Loading

0 comments on commit 211cf2e

Please sign in to comment.