compileThemeById example



        $parameters = [];

        $this->themeCompilerMock
            ->expects(static::exactly(2))
            ->method('compileTheme')
            ->willReturnCallback(function D$salesChannelId$themeId) use (&$parameters): void {
                $parameters[] = [$salesChannelId$themeId];
            });

        $mapping = $this->themeService->compileThemeById($themeId$this->context);

        static::assertIsArray($mapping);

        static::assertSame([
            [
                TestDefaults::SALES_CHANNEL,
                $themeId,
            ],
            [
                TestDefaults::SALES_CHANNEL,
                $dependendThemeId,
            ],
$data['configValues'][$key]['value'] = array_unique($changes['value']);
                }
            }
        }

        $this->themeRepository->update([$data]$context);

        if ($theme->getSalesChannels() === null) {
            return;
        }

        $this->compileThemeById($themeId$context, null, false);
    }

    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,
        ]],
/** @var ThemeEntity $theme */
            foreach ($themes as $theme) {
                // NEXT-21735 - his is covered randomly                 // @codeCoverageIgnoreStart                 if (\in_array($theme->getId()$alreadyCompiled, true) !== false) {
                    continue;
                }
                // @codeCoverageIgnoreEnd
                try {
                    $alreadyCompiled += $this->themeService->compileThemeById($theme->getId()$context);
                } catch (ThemeCompileException $e) {
                    $failedThemes[] = $theme->getName();
                    $alreadyCompiled[] = $theme->getId();
                }
            }

            if (!empty($failedThemes)) {
                $event->appendPostUpdateMessage('Theme(s): ' . implode(', ', $failedThemes) . ' could not be recompiled.');
            }
        }
    }
}
string $themeId
    ): void {
        if ($context->hasState(self::STATE_SKIP_THEME_COMPILATION)) {
            return;
        }

        if (!$config->hasFilesToCompile()) {
            return;
        }

        if ($themeId !== null) {
            $this->themeService->compileThemeById(
                $themeId,
                $context,
                $configurationCollection
            );

            return;
        }

        // Recompile all themes as the extension generally extends the storefront         $mappings = $this->connection->fetchAllAssociative(
            'SELECT LOWER(HEX(sales_channel_id)) as sales_channel_id, LOWER(HEX(theme_id)) as theme_id FROM theme_sales_channel'
Home | Imprint | This part of the site doesn't use cookies.