diff --git a/src/Asset/Patcher/Adapter/MetadataAdapter.php b/src/Asset/Patcher/Adapter/MetadataAdapter.php index 142743839..9699d8e9b 100644 --- a/src/Asset/Patcher/Adapter/MetadataAdapter.php +++ b/src/Asset/Patcher/Adapter/MetadataAdapter.php @@ -16,6 +16,7 @@ namespace Pimcore\Bundle\StudioBackendBundle\Asset\Patcher\Adapter; +use Pimcore\Bundle\StudioBackendBundle\Asset\Service\Data\CustomMetadataServiceInterface; use Pimcore\Bundle\StudioBackendBundle\Exception\Api\InvalidArgumentException; use Pimcore\Bundle\StudioBackendBundle\Metadata\Repository\MetadataRepositoryInterface; use Pimcore\Bundle\StudioBackendBundle\Patcher\Service\Loader\PatchAdapterInterface; @@ -109,6 +110,10 @@ private function processNewMetadataEntry(array $metadata): array throw new InvalidArgumentException('Metadata name is required'); } + if(in_array($metadata['name'], CustomMetadataServiceInterface::DEFAULT_METADATA, true)) { + return $this->addDefaultMetadata($metadata); + } + $predefined = $this->metadataRepository->getPredefinedMetadataByName($metadata['name']); if (!$predefined) { @@ -135,4 +140,14 @@ private function findIndexOfMatch(array $metadata, array $patchMetadata): int|bo // Return the key of the first match return !empty($match) ? current($match) : false; } + + private function addDefaultMetadata(array $metadata): array + { + return [ + 'name' => $metadata['name'], + 'language' => $metadata['language'] ?? '', + 'type' => 'input', + 'data' => $metadata['data'] ?? null, + ]; + } }