buildConfig example


    private function getConfig(Template $template, Shop $shop): array
    {
        $config = $this->inheritance->buildConfig($template$shop);
        $config['shopware-revision'] = md5($this->release->getRevision() . $this->uniqueIdGenerator->getUniqueId());

        /** @var ArrayCollection<int, mixed> $collection */
        $collection = new ArrayCollection();

        $this->eventManager->collect(
            'Theme_Compiler_Collect_Less_Config',
            $collection,
            ['shop' => $shop, 'template' => $template]
        );

        
return new FrameworkExtension();
    }

    /** * {@inheritdoc} */
    public function build(ContainerBuilder $container): void
    {
        $container->setParameter('locale', 'en-GB');
        $environment = (string) $container->getParameter('kernel.environment');

        $this->buildConfig($container$environment);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection/'));
        $loader->load('services.xml');
        $loader->load('acl.xml');
        $loader->load('cache.xml');
        $loader->load('api.xml');
        $loader->load('app.xml');
        $loader->load('custom-field.xml');
        $loader->load('data-abstraction-layer.xml');
        $loader->load('demodata.xml');
        $loader->load('event.xml');
        


    public function build(ContainerBuilder $container): void
    {
        parent::build($container);

        $container->addCompilerPass(new ElasticsearchMigrationCompilerPass());

        // Needs to run before the ProfilerPass         $container->addCompilerPass(new ElasticsearchProfileCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 5000);

        $this->buildConfig($container);
    }

    protected function createContainerExtension(): ?ExtensionInterface
    {
        return new ElasticsearchExtension();
    }

    private function buildConfig(ContainerBuilder $container): void
    {
        $locator = new FileLocator('Resources/config');

        
$templateManager = $this->container->get('template');
        $templateManager->addPluginsDir(
            $inheritance->getSmartyDirectories($shop->getTemplate())
        );

        $themeSettings = $templateManager->getTemplateVars('theme');
        if (!empty($themeSettings)) {
            return;
        }

        $config = $inheritance->buildConfig(
            $shop->getTemplate(),
            $shop,
            false
        );

        $templateManager->assign('theme', $config);
    }
}
if ($this->getShop() !== null) {
            $defaultContext = [
                'sConfig' => $config,
                'sShop' => $config->get('shopName'),
                'sShopURL' => ($this->getShop()->getSecure() ? 'https://' : 'http://') . $this->getShop()->getHost() . $this->getShop()->getBaseUrl(),
            ];

            // Add theme to the context if given shop (or its main shop) has a template.             $theme = null;
            if ($this->getShop()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getTemplate()$this->getShop(), false);
            } elseif ($this->getShop()->getMain() && $this->getShop()->getMain()->getTemplate()) {
                $theme = $inheritance->buildConfig($this->getShop()->getMain()->getTemplate()$this->getShop(), false);
            }

            if ($theme) {
                $keys = $eventManager->filter(
                    'TemplateMail_CreateMail_Available_Theme_Config',
                    $this->themeVariables,
                    ['theme' => $theme]
                );

                
parent::build($container);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection'));
        $loader->load('services.xml');
        $loader->load('seo.xml');
        $loader->load('controller.xml');
        $loader->load('theme.xml');

        /** @var string $environment */
        $environment = $container->getParameter('kernel.environment');

        $this->buildConfig($container$environment);

        $container->setParameter('storefrontRoot', $this->getPath());

        $container->addCompilerPass(new DisableTemplateCachePass());
        $container->addCompilerPass(new ReverseProxyCompilerPass());
        $container->addCompilerPass(new StorefrontMigrationReplacementCompilerPass());
    }

    private function buildConfig(ContainerBuilder $container, string $environment): void
    {
        $locator = new FileLocator('Resources/config');

        

    public function initTemplate($mailing)
    {
        $template = clone Shopware()->Template();
        $shop = Shopware()->Shop();
        $inheritance = Shopware()->Container()->get('theme_inheritance');

        $config = $inheritance->buildConfig(
            $shop->getTemplate(),
            $shop,
            false
        );

        $user = $this->getMailingUserByEmail(Shopware()->Config()->get('Mail'));
        $template->assign('sUser', $user, true);
        $hash = $this->createHash((int) $user['mailaddressID'](int) $mailing['id']);
        $template->assign('sCampaignHash', $hash, true);
        $template->assign('sRecommendations', $this->getMailingSuggest($mailing['id']$user['userID']), true);
        $template->assign('sVoucher', $this->getMailingVoucher($mailing['id']), true);
        
/** * {@inheritdoc} */
    public function build(ContainerBuilder $container): void
    {
        /** @var string $environment */
        $environment = $container->getParameter('kernel.environment');

        parent::build($container);

        $this->buildConfig($container$environment);

        $loader = new XmlFileLoader($containernew FileLocator(__DIR__ . '/DependencyInjection/'));
        $loader->load('services.xml');

        if ($environment === 'dev') {
            $loader->load('services_dev.xml');
        }

        $container->addCompilerPass(new RemoveDevServices());
    }

    
$shop = $this->container->get('shop');
        if (!$shop instanceof Shop) {
            return;
        }

        $template = $shop->getTemplate();
        if (!$template instanceof Template) {
            return;
        }

        $inheritance = $this->container->get('theme_inheritance');
        $config = $inheritance->buildConfig($template$shop, false);

        $this->container->get('template')->addPluginsDir(
            $inheritance->getSmartyDirectories($template)
        );
        $this->View()->assign('theme', $config);
    }
}
Home | Imprint | This part of the site doesn't use cookies.