getThemeId example

#[Package('storefront')] final class DeleteThemeFilesHandler
{
    public function __construct(
        private readonly FilesystemOperator $filesystem,
        private readonly AbstractThemePathBuilder $pathBuilder
    ) {
    }

    public function __invoke(DeleteThemeFilesMessage $message): void
    {
        $currentPath = $this->pathBuilder->assemblePath($message->getSalesChannelId()$message->getThemeId());

        if ($currentPath === $message->getThemePath()) {
            return;
        }

        $this->filesystem->deleteDirectory($message->getThemePath());
    }
}

class DeleteThemeFilesMessageTest extends TestCase
{
    public function testStruct(): void
    {
        $message = new DeleteThemeFilesMessage('path', 'salesChannel', 'theme');

        static::assertEquals('path', $message->getThemePath());
        static::assertEquals('salesChannel', $message->getSalesChannelId());
        static::assertEquals('theme', $message->getThemeId());
    }
}

    public function config(array $context, string $key)
    {
        return $this->config->config($key$this->getSalesChannelId($context));
    }

    /** * @return string|bool|array|float|int|null */
    public function theme(array $context, string $key)
    {
        return $this->config->theme($key$this->getContext($context)$this->getThemeId($context));
    }

    private function getSalesChannelId(array $context): ?string
    {
        if (isset($context['context'])) {
            $salesChannelContext = $context['context'];
            if ($salesChannelContext instanceof SalesChannelContext) {
                return $salesChannelContext->getSalesChannelId();
            }
        }
        if (isset($context['salesChannel'])) {
            
/** * @internal */
#[Package('storefront')] class DatabaseAvailableThemeProviderTest extends TestCase
{
    use IntegrationTestBehaviour;
    use SalesChannelApiTestBehaviour;

    public function testReadSalesChannels(): void
    {
        $themeId = $this->getThemeId();

        $firstSc = $this->createSalesChannel();
        $secondSc = $this->createSalesChannel([
            'active' => false,
            'themes' => [
                [
                    'id' => $themeId,
                ],
            ],
        ]);

        
public static function getSubscribedEvents(): array
    {
        return [
            ThemeConfigChangedEvent::class => 'invalidate',
            ThemeAssignedEvent::class => 'assigned',
            ThemeConfigResetEvent::class => 'reset',
        ];
    }

    public function invalidate(ThemeConfigChangedEvent $event): void
    {
        $tags = [CachedResolvedConfigLoader::buildName($event->getThemeId())];

        if (!$this->fineGrainedCache) {
            $this->cacheInvalidator->invalidate(['shopware.theme']);

            return;
        }

        $keys = array_keys($event->getConfig());

        foreach ($keys as $key) {
            $tags[] = ThemeConfigValueAccessor::buildName($key);
        }
/** * @extends EntityCollection<ThemeTranslationEntity> */
#[Package('storefront')] class ThemeTranslationCollection extends EntityCollection
{
    /** * @return list<string> */
    public function getThemeIds(): array
    {
        return $this->fmap(fn (ThemeTranslationEntity $themeTranslation) => $themeTranslation->getThemeId());
    }

    public function filterByThemeId(string $id): self
    {
        return $this->filter(fn (ThemeTranslationEntity $themeTranslation) => $themeTranslation->getThemeId() === $id);
    }

    /** * @return list<string> */
    public function getLanguageIds(): array
    {
string $themeId,
        Context $context,
        ?StorefrontPluginConfigurationCollection $configurationCollection = null,
        bool $withAssets = true
    ): array {
        $mappings = $this->getThemeDependencyMapping($themeId);

        $compiledThemeIds = [];
        foreach ($mappings as $mapping) {
            $this->themeCompiler->compileTheme(
                $mapping->getSalesChannelId(),
                $mapping->getThemeId(),
                $this->configLoader->load($mapping->getThemeId()$context),
                $configurationCollection ?? $this->extensionRegistry->getConfigurations(),
                $withAssets,
                $context
            );

            $compiledThemeIds[] = $mapping->getThemeId();
        }

        return $compiledThemeIds;
    }

    
Home | Imprint | This part of the site doesn't use cookies.