UpdateThumbnailsMessage example



    public function testItDispatchesUpdateThumbnailsMessageWithCorrectStrictProperty(): void
    {
        $this->createValidMediaFiles();
        $newMedia = $this->getNewMediaEntities();

        $output = new BufferedOutput();

        $affectedMediaIds = [...array_combine($this->initialMediaIds, $this->initialMediaIds), ...$newMedia->getIds()];

        $expectedMessageStrict = new UpdateThumbnailsMessage();

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

        $expectedMessageStrict->setIsStrict(true);
        $expectedMessageStrict->setMediaIds($affectedMediaIds);

        $expectedMessageNonStrict = new UpdateThumbnailsMessage();

        

    }

    /** * @param RepositoryIterator<MediaCollection> $mediaIterator */
    private function generateAsynchronous(RepositoryIterator $mediaIterator, Context $context): void
    {
        $batchCount = 0;
        $this->io->comment('Generating batch jobs...');
        while (($result = $mediaIterator->fetch()) !== null) {
            $msg = new UpdateThumbnailsMessage();
            $msg->setIsStrict($this->isStrict);
            $msg->setMediaIds($result->getEntities()->getIds());

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

            $this->messageBus->dispatch($msg);
            ++$batchCount;
        }

        ]$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 UpdateThumbnailsMessage();
        $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()]);
        
Home | Imprint | This part of the site doesn't use cookies.