GenerateThumbnailsMessage example

$media = $this->updateMediaEntity(
            $mediaFile,
            $destination,
            $currentMedia,
            $metaData,
            $mediaType,
            $context
        );

        $this->saveFileToMediaDir($mediaFile$media);

        $message = new GenerateThumbnailsMessage();
        $message->setMediaIds([$mediaId]);

        if (Feature::isActive('v6.6.0.0')) {
            $message->setContext($context);
        } else {
            $message->withContext($context);
        }

        $this->messageBus->dispatch($message);
    }

    

        ]$this->context);

        /** @var MediaEntity $media */
        $media = $this->mediaRepository->search(new Criteria([$media->getId()])$this->context)->get($media->getId());

        $this->getPublicFilesystem()->writeStream(
            $this->urlGenerator->getRelativeMediaUrl($media),
            fopen(__DIR__ . '/../fixtures/shopware-logo.png', 'rb')
        );

        $msg = new GenerateThumbnailsMessage();
        $msg->setMediaIds([$media->getId()]);

        if (Feature::isActive('v6.6.0.0')) {
            $msg->setContext($this->context);
        } else {
            $msg->withContext($this->context);
        }

        $this->handler->__invoke($msg);

        $criteria = new Criteria([$media->getId()]);
        
$mediaSearchResult->method('getEntities')->willReturn($mediaWithRelatedFileName);
        $this->mediaRepository->method('search')->willReturn($mediaSearchResult);

        $file = tmpfile();
        static::assertIsResource($file);
        $tempMeta = stream_get_meta_data($file);
        $mediaFile = new MediaFile($tempMeta['uri'], 'image/png', 'png', 0);

        $context = Context::createDefaultContext(new AdminApiSource(Uuid::randomHex()));
        $mediaId = Uuid::randomHex();

        $message = new GenerateThumbnailsMessage();
        $message->setMediaIds([$mediaId]);

        if (Feature::isActive('v6.6.0.0')) {
            $message->setContext($context);
        } else {
            $message->withContext($context);
        }

        $this->mediaRepository
            ->expects(static::once())
            ->method('update')
            
Home | Imprint | This part of the site doesn't use cookies.