getThemes example


    protected function getUnusedThemes(array $usingThemes = []): array
    {
        if (!$this->container->has(StorefrontPluginRegistry::class)) {
            return [];
        }

        $themeRegistry = $this->container->get(StorefrontPluginRegistry::class);

        $unusedThemes = $themeRegistry->getConfigurations()->getThemes()->filter(fn (StorefrontPluginConfiguration $theme) => !\in_array($theme->getTechnicalName()$usingThemes, true))->map(fn (StorefrontPluginConfiguration $theme) => $theme->getTechnicalName());

        return array_values($unusedThemes);
    }

    /** * Second parameter $unusedThemes is used for external dependencies * * @param list<string> $unusedThemes * * @return array<string, string> */
    
return $choices;
    }

    /** * @return array<string> */
    protected function getThemeChoices(): array
    {
        $choices = [];

        foreach ($this->pluginRegistry->getConfigurations()->getThemes() as $theme) {
            $choices[] = $theme->getTechnicalName();
        }

        return $choices;
    }

    private function parseSalesChannelAnswer(string $answer): ?string
    {
        $parts = explode('|', $answer);
        $salesChannelId = trim(array_pop($parts));

        
private readonly EntityRepository $themeChildRepository,
        private readonly Connection $connection,
        private readonly ?AbstractStorefrontPluginConfigurationFactory $pluginConfigurationFactory
    ) {
    }

    public function refreshThemes(
        Context $context,
        ?StorefrontPluginConfigurationCollection $configurationCollection = null
    ): void {
        if ($configurationCollection === null) {
            $configurationCollection = $this->pluginRegistry->getConfigurations()->getThemes();
        }

        // iterate over all theme configs in the filesystem (plugins/bundles)         foreach ($configurationCollection as $config) {
            $this->refreshTheme($config$context);
        }
    }

    public function refreshTheme(StorefrontPluginConfiguration $configuration, Context $context): void
    {
        $themeData = [];
        
$this->loadAppsFromDir(__DIR__ . '/fixtures/Apps/noThemeNoCss');

        $registry = $this->getContainer()
            ->get(StorefrontPluginRegistry::class);

        static::assertInstanceOf(
            StorefrontPluginConfiguration::class,
            $registry->getConfigurations()->getByTechnicalName('SwagNoThemeNoCss')
        );

        static::assertNull(
            $registry->getConfigurations()->getThemes()->getByTechnicalName('SwagNoThemeNoCss')
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.