/** * @When I generate the container */ public function iGenerateTheContainer() { $serviceFolders = implode(',', $this->configuration->getServicesFolders()); $isDebug = $this->configuration->getDebug() ? 'true' : 'false'; $isTest = $this->configuration->isTestEnvironment() ? 'true' : 'false'; exec('php features/bootstrap/generate.php ' . $serviceFolders . ' ' . $isDebug . ' ' . $isTest); $this->generatedServices = unserialize(file_get_contents('serialized.container')); }
function it_loads_an_existing_container_if_it_exists_when_not_in_debug_mode(ContainerBuilder $containerBuilder, ContainerLoader $containerLoader, Filesystem $filesystem, Configuration $configuration) { $configuration->getDebug()->willReturn(false); $filesystem->exists(Argument::any())->willReturn(true); $filesystem->dump(Argument::any())->shouldNotBeCalled(); $containerLoader->loadFrom($this->containerFile)->willReturn($containerBuilder); $this->build($configuration)->shouldReturn($containerBuilder); }
function let(MageApp $app, Configuration $generatorConfig, StoreConfigCompilerPass $configCompilerPass, InjectableCompilerPass $injectableCompilerPass) { $generatorConfig->getContainerFilePath()->willReturn('container.php'); $generatorConfig->getDebug()->willReturn(true); $generatorConfig->getServicesFolders()->willReturn(['app/etc']); $generatorConfig->getServicesFormat()->willReturn('xml'); $generatorConfig->getCompilerPasses()->willReturn([]); $generatorConfig->isTestEnvironment()->willReturn(false); $services = ['app' => $app, 'generatorConfig' => $generatorConfig, 'storeConfigCompilerPass' => $configCompilerPass, 'injectableCompilerPass' => $injectableCompilerPass]; $this->beConstructedWith($services); }
function let(Configuration $generatorConfig) { $generatorConfig->getContainerFilePath()->willReturn('container.php'); $generatorConfig->getDebug()->willReturn(true); $generatorConfig->getServicesFolders()->willReturn(['app/etc']); $generatorConfig->getServicesFormat()->willReturn('xml'); $generatorConfig->getCompilerPasses()->willReturn([]); $generatorConfig->isTestEnvironment()->willReturn(false); $services = ['generatorConfig' => $generatorConfig]; $this->beConstructedWith($services); }
/** * @param Configuration $configuration * * @return Container */ public function build(Configuration $configuration) { $containerFilePath = $configuration->getContainerFilePath(); $containerHasBeenBuilt = $this->filesystem->exists($containerFilePath); $isDebug = $configuration->getDebug(); if ($isDebug) { $container = $this->compile($configuration); } else { if ($containerHasBeenBuilt) { $container = $this->containerLoader->loadFrom($containerFilePath); } else { $container = $this->compile($configuration); $this->filesystem->dump($container); } } return $container; }
/** * @return Container */ private function buildContainer() { $containerConfigCache = new ConfigCache($this->configuration->getContainerFilePath(), $this->configuration->getDebug()); $builder = new Builder(new ConfigurationLoader(new SymfonyContainerBuilder(), new DelegatingLoaderFactory(), new SymfonyFilesystem()), new ContainerLoader(), new Filesystem(new SymfonyFilesystem(), new ContainerDumperFactory(), $containerConfigCache)); return $builder->build($this->configuration); }