ThemeAssignedEvent example

ThemeAssignedEvent::class => 'assigned',
                ThemeConfigResetEvent::class => 'reset',
            ],
            CachedResolvedConfigLoaderInvalidator::getSubscribedEvents()
        );
    }

    public function testAssigned(): void
    {
        $themeId = Uuid::randomHex();
        $salesChannelId = Uuid::randomHex();
        $event = new ThemeAssignedEvent($themeId$salesChannelId);
        $name = 'theme-config-' . $themeId;

        $expectedInvalidatedTags = [
            $name,
            CachedDomainLoader::CACHE_KEY,
            'translation.catalog.' . $salesChannelId,
        ];

        $this->cachedResolvedConfigLoaderInvalidator->assigned($event);

        static::assertEquals(
            
$themeId = Uuid::randomHex();

        $this->themeSalesChannelRepositoryMock->expects(static::once())->method('upsert')->with(
            [[
                'themeId' => $themeId,
                'salesChannelId' => TestDefaults::SALES_CHANNEL,
            ]],
            $this->context
        );

        $this->eventDispatcherMock->expects(static::once())->method('dispatch')->with(
            new ThemeAssignedEvent($themeId, TestDefaults::SALES_CHANNEL)
        );

        $this->themeCompilerMock->expects(static::once())->method('compileTheme')->with(
            TestDefaults::SALES_CHANNEL,
            $themeId,
            static::anything(),
            static::anything(),
            true,
            $this->context
        );

        
public function assignTheme(string $themeId, string $salesChannelId, Context $context, bool $skipCompile = false): bool
    {
        if (!$skipCompile) {
            $this->compileTheme($salesChannelId$themeId$context);
        }

        $this->themeSalesChannelRepository->upsert([[
            'themeId' => $themeId,
            'salesChannelId' => $salesChannelId,
        ]]$context);

        $this->dispatcher->dispatch(new ThemeAssignedEvent($themeId$salesChannelId));

        return true;
    }

    public function resetTheme(string $themeId, Context $context): void
    {
        $criteria = new Criteria([$themeId]);
        $theme = $this->themeRepository->search($criteria$context)->get($themeId);

        if (!$theme) {
            throw new InvalidThemeException($themeId);
        }
Home | Imprint | This part of the site doesn't use cookies.