/** * @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); }
/** * @Given the store has :themeName theme */ public function storeHasTheme($themeName) { $theme = $this->themeFactory->createNamed($themeName); $theme->setTitle($themeName); $theme->setPath(sys_get_temp_dir() . '/theme-' . $theme->getCode() . time() . '/'); if (!file_exists($theme->getPath())) { mkdir($theme->getPath(), 0777, true); } $this->themeRepository->add($theme); $this->sharedStorage->set('theme', $theme); }
/** * {@inheritdoc} */ public function add(ResourceInterface $resource) { try { return $this->unstableRepository->add($resource); } catch (\Exception $exception) { return $this->fallbackRepository->add($resource); } }
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(); }