/** * @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->findOneBySlug('sylius/first-test-theme')); }
/** * @param string $themeName * * @return ThemeInterface * * @throws \InvalidArgumentException If theme is not found */ private function getTheme($themeName) { $theme = $this->themeRepository->findOneBySlug($themeName); if (null === $theme) { throw new \InvalidArgumentException(sprintf('Theme "%s" not found!', $themeName)); } return $theme; }
function it_returns_theme_list_in_hierarchized_order(ThemeRepositoryInterface $themeRepository, ThemeInterface $firstTheme, ThemeInterface $secondTheme) { $firstTheme->getSlug()->willReturn("foo/bar1"); $firstTheme->getParentsSlugs()->willReturn(["foo/bar2"]); $secondTheme->getSlug()->willReturn("foo/bar2"); $secondTheme->getParentsSlugs()->willReturn([]); $themeRepository->findOneBySlug("foo/bar1")->willReturn($firstTheme); $themeRepository->findOneBySlug("foo/bar2")->willReturn($secondTheme); $this->getThemeHierarchy($firstTheme)->shouldReturn([$firstTheme, $secondTheme]); }