diff --git a/src/Asset/Patcher/Adapter/MetadataAdapter.php b/src/Asset/Patcher/Adapter/MetadataAdapter.php index 142743839..154f01db9 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; @@ -25,6 +26,7 @@ use Pimcore\Model\Element\ElementInterface; use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag; use function array_key_exists; +use function in_array; /** * @internal @@ -109,6 +111,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 +141,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, + ]; + } }