/** * {@inheritdoc} */ public function locate($template, $currentPath = null, $first = true) { if (!$template instanceof TemplateReferenceInterface) { throw new \InvalidArgumentException('The template must be an instance of TemplateReferenceInterface.'); } $themes = $this->themeContext->getThemeHierarchy(); foreach ($themes as $theme) { try { return $this->templateLocator->locateTemplate($template, $theme); } catch (ResourceNotFoundException $exception) { // Ignore if resource cannot be found in given theme. } } return $this->decoratedFileLocator->locate($template, $currentPath, $first); }
/** * @param string $id * * @return \Generator */ private function getPossibleIds($id) { $themes = $this->themeContext->getThemeHierarchy(); foreach ($themes as $theme) { (yield $id . "|" . $theme->getSlug()); } (yield $id); }
/** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { $this->usedTheme = $this->themeContext->getTheme(); $this->themeHierarchy = $this->themeContext->getThemeHierarchy(); $this->allThemes = $this->themeRepository->findAll(); }
function it_falls_back_to_decorated_template_locator_if_there_are_no_themes_active(FileLocatorInterface $decoratedFileLocator, ThemeContextInterface $themeContext, TemplateReferenceInterface $template) { $themeContext->getThemeHierarchy()->willReturn([]); $decoratedFileLocator->locate($template, Argument::cetera())->willReturn('/app/template/path'); $this->locate($template)->shouldReturn('/app/template/path'); }
function it_returns_id_if_there_is_no_given_choice_translation(TranslatorInterface $translator, ThemeContextInterface $themeContext, ThemeInterface $theme) { $theme->getSlug()->willReturn('theme/slug'); $themeContext->getThemeHierarchy()->willReturn([$theme]); $translator->transChoice('id|theme/slug', 42, Argument::cetera())->willReturn('id|theme/slug'); $translator->transChoice('id', 42, Argument::cetera())->willReturn('id'); $this->transChoice('id', 42)->shouldReturn('id'); }