/** * @param string $themeName * * @return ThemeInterface * * @throws \InvalidArgumentException If theme is not found */ private function getTheme($themeName) { $theme = $this->themeRepository->findOneByName($themeName); if (null === $theme) { throw new \InvalidArgumentException(sprintf('Theme "%s" not found!', $themeName)); } return $theme; }
/** * @param string $themeName * * @return ThemeInterface */ private function getTheme($themeName) { $theme = $this->themeRepository->findOneByName($themeName); if (null === $theme) { throw new NotFoundHttpException(sprintf('Theme with name "%s" not found', $themeName)); } return $theme; }
/** * @param ThemeInterface $theme */ private function updateTheme(ThemeInterface $theme) { $existingTheme = $this->themeRepository->findOneByName($theme->getName()); if (null !== $existingTheme) { $theme = $this->themeMerger->merge($existingTheme, $theme); } $this->themeRepository->add($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; } $this->themeContext->setTheme($this->themeRepository->findOneByName('sylius/first-test-theme')); }
function it_returns_theme_list_in_hierarchized_order(ThemeRepositoryInterface $themeRepository, ThemeInterface $firstTheme, ThemeInterface $secondTheme) { $firstTheme->getName()->willReturn('foo/bar1'); $firstTheme->getParentsNames()->willReturn(['foo/bar2']); $secondTheme->getName()->willReturn('foo/bar2'); $secondTheme->getParentsNames()->willReturn([]); $themeRepository->findOneByName('foo/bar1')->willReturn($firstTheme); $themeRepository->findOneByName('foo/bar2')->willReturn($secondTheme); $this->getThemeHierarchy($firstTheme)->shouldReturn([$firstTheme, $secondTheme]); }
/** * {@inheritdoc} */ public function getTheme() { try { /** @var ChannelInterface $channel */ $channel = $this->channelContext->getChannel(); return $this->themeRepository->findOneByName($channel->getThemeName()); } catch (ChannelNotFoundException $exception) { return null; } catch (\Exception $exception) { return null; } }
function it_returns_null_if_channel_has_no_theme(ChannelContextInterface $channelContext, ThemeRepositoryInterface $themeRepository, ChannelInterface $channel) { $channelContext->getChannel()->willReturn($channel); $channel->getThemeName()->willReturn(null); $themeRepository->findOneByName(null)->willReturn(null); $this->getTheme()->shouldReturn(null); }
/** * {@inheritdoc} */ public function findOneByName($name) { try { return $this->unstableRepository->findOneByName($name); } catch (\Exception $exception) { return $this->fallbackRepository->findOneByName($name); } }
public function it_returns_a_theme(TenantContextInterface $tenantContext, ThemeAwareTenantInterface $tenant, ThemeInterface $theme, ThemeRepositoryInterface $themeRepository) { $tenantContext->getTenant()->willReturn($tenant); $tenant->getSubdomain()->willReturn('subdomain1'); $tenant->getCode()->willReturn('code'); $tenant->getThemeName()->willReturn('swp/default-theme'); $themeRepository->findOneByName('swp/default-theme@code')->willReturn($theme); $this->getTheme()->shouldReturn($theme); }
function it_ensures_cohesion_between_parent_themes(ThemeLoaderInterface $themeLoader, ThemeRepositoryInterface $themeRepository, ThemeMergerInterface $themeMerger, ThemeInterface $loadedTheme, ThemeInterface $loadedParentTheme, ThemeInterface $existingParentTheme) { $themeRepository->findAll()->willReturn([$existingParentTheme]); $existingParentTheme->getName()->willReturn('parent-theme/name'); $themeLoader->load()->willReturn([$loadedTheme, $loadedParentTheme]); $loadedTheme->getName()->willReturn('theme/name'); $loadedTheme->getParents()->willReturn([$loadedParentTheme]); $themeRepository->findOneByName('theme/name')->willReturn(null); $loadedParentTheme->getName()->willReturn('parent-theme/name'); $loadedParentTheme->getParents()->willReturn([]); $themeRepository->findOneByName('parent-theme/name')->willReturn($existingParentTheme); $loadedTheme->removeParent($loadedParentTheme)->shouldBeCalled(); $loadedTheme->addParent($existingParentTheme)->shouldBeCalled(); $themeMerger->merge($existingParentTheme, $loadedParentTheme)->willReturn($existingParentTheme); $themeRepository->add($loadedTheme)->shouldBeCalled(); $themeRepository->add($existingParentTheme)->shouldBeCalled(); $themeRepository->add($loadedParentTheme)->shouldNotBeCalled(); $this->synchronize(); }
/** * {@inheritdoc} */ public function getTheme() { /* @var ThemeAwareTenantInterface $tenant */ $tenant = $this->tenantContext->getTenant(); $key = md5($tenant->getCode()); if (array_key_exists($key, $this->themes)) { return $this->themes[$key]; } if ($this->cacheService->contains('theme_' . $key)) { return $this->themes[$key] = $this->cacheService->fetch('theme_' . $key); } $theme = $this->themeRepository->findOneByName($this->resolveThemeName($tenant)); unset($tenant); if (null === $theme) { throw new NoThemeException(); } $this->themes[$key] = $theme; $this->cacheService->save('theme_' . $key, $theme, 600); return $theme; }
/** * @Given the store has :themeName theme */ public function storeHasTheme($themeName) { $this->testThemeConfigurationManager->add(['name' => $themeName]); $this->sharedStorage->set('theme', $this->themeRepository->findOneByName($themeName)); }
function it_throws_not_found_http_exception_if_theme_with_given_id_cannot_be_found(ThemeRepositoryInterface $themeRepository) { $themeRepository->findOneByName('theme/name')->willReturn(null); $this->shouldThrow(new NotFoundHttpException('Theme with name "theme/name" not found'))->during('streamScreenshotAction', ['theme/name', 666]); }
/** * @Transform /^"([^"]+)" theme$/ * @Transform /^theme "([^"]+)"$/ * @Transform :theme */ public function getThemeByThemeName($themeName) { return $this->themeRepository->findOneByName($themeName); }