/** * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { // don't do anything if it's not the master request return; } $this->themeContext->setTheme($this->themeRepository->findByLogicalName('sylius/first-test-theme')); }
/** * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { // don't do anything if it's not the master request return; } $themeName = $this->session->get('theme'); if (null === $themeName) { return; } if (null === ($theme = $this->themeRepository->findByLogicalName($themeName))) { return; } $this->themeContext->setTheme($theme); }
/** * {@inheritdoc} */ public function warmUp($cacheDir) { $templates = []; $themes = $this->themeRepository->findAll(); /** @var TemplateReferenceInterface $template */ foreach ($this->finder->findAllTemplates() as $template) { $this->themeContext->clear(); foreach ($themes as $theme) { $this->themeContext->setTheme($theme); $path = $this->locator->locate($template); $templates[$template->getLogicalName() . "|" . $theme->getLogicalName()] = $path; } $templates[$template->getLogicalName()] = $this->locator->locate($template); } $this->writeCacheFile($cacheDir . '/templates.php', sprintf('<?php return %s;', var_export($templates, true))); }