getDefaultMapping example

$media = [
            'id' => Uuid::randomHex(),
            'mediaFolderId' => Uuid::randomHex(),
            'url' => 'https://shopware.test/foo/bar/media.png',
            'private' => false,
            'mediaType' => 'image/png',
            'translations' => [
                'DEFAULT' => $mediaTranslations,
            ],
        ];

        $mapping = $this->getDefaultMapping(MediaDefinition::ENTITY_NAME);

        $config = new Config($mapping[][]);
        $mappingPipe = new KeyMappingPipe($mapping, true);
        $pipeInResult = $mappingPipe->in($config$media);
        static::assertInstanceOf(\Traversable::class$pipeInResult);
        $mappedMedia = iterator_to_array($pipeInResult);

        static::assertSame($media['id']$mappedMedia['id']);
        static::assertSame($media['mediaFolderId']$mappedMedia['folder_id']);
        static::assertSame($media['url']$mappedMedia['url']);
        static::assertSame($media['private']$mappedMedia['private']);
        
Home | Imprint | This part of the site doesn't use cookies.