/** * @param array $configurations * * @return ThemeInterface[] */ private function initializeThemes(array $configurations) { $themes = []; foreach ($configurations as $configuration) { /** @var ThemeInterface $theme */ $themes[$configuration['name']] = $this->themeFactory->createNamed($configuration['name']); } return $themes; }
function it_throws_an_exception_if_there_is_a_circular_dependency_found(ConfigurationProviderInterface $configurationProvider, ThemeFactoryInterface $themeFactory, HydrationInterface $themeHydrator, CircularDependencyCheckerInterface $circularDependencyChecker, ThemeInterface $firstTheme, ThemeInterface $secondTheme) { $configurationProvider->getConfigurations()->willReturn([['name' => 'first/theme', 'parents' => ['second/theme'], 'authors' => []], ['name' => 'second/theme', 'parents' => ['first/theme'], 'authors' => []]]); $themeFactory->createNamed('first/theme')->willReturn($firstTheme); $themeFactory->createNamed('second/theme')->willReturn($secondTheme); $themeHydrator->hydrate(['name' => 'first/theme', 'parents' => [$secondTheme], 'authors' => []], $firstTheme)->willReturn($firstTheme); $themeHydrator->hydrate(['name' => 'second/theme', 'parents' => [$firstTheme], 'authors' => []], $secondTheme)->willReturn($secondTheme); $circularDependencyChecker->check(Argument::cetera())->willThrow(CircularDependencyFoundException::class); $this->shouldThrow(new ThemeLoadingFailedException('Circular dependency found.'))->during('load'); }
/** * @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); }