Пример #1
0
 /**
  * {@inheritdoc}
  *
  * @param ThemeLoaderInterface $themeLoader
  */
 public function __construct(ThemeLoaderInterface $themeLoader, $interface)
 {
     parent::__construct($interface);
     $themes = $themeLoader->load();
     foreach ($themes as $theme) {
         $this->add($theme);
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function synchronize()
 {
     $persistedThemes = $this->themeRepository->findAll();
     $loadedThemes = $this->themeLoader->load();
     $removedThemes = $this->removeAbandonedThemes($persistedThemes, $loadedThemes);
     $existingThemes = array_udiff($persistedThemes, $removedThemes, function (ThemeInterface $firstTheme, ThemeInterface $secondTheme) {
         return (int) ($firstTheme->getName() === $secondTheme->getName());
     });
     $this->updateThemes($existingThemes, $loadedThemes);
 }
 private function loadThemesIfNeeded()
 {
     if ($this->themesLoaded) {
         return;
     }
     $themes = $this->themeLoader->load();
     foreach ($themes as $theme) {
         $this->themes[$theme->getName()] = $theme;
     }
     $this->themesLoaded = true;
 }
Пример #4
0
 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();
 }