/** * @return Container */ private function _buildContainer() { $this->_generatorConfig->addCompilerPass($this->_storeConfigCompilerPass); $this->_generatorConfig->addCompilerPass($this->_injectableCompilerPass); $generator = new ContainerGenerator($this->_generatorConfig); return $this->_container = $generator->getContainer(); }
function it_memoizes_container(Configuration $generatorConfig, StoreConfigCompilerPass $configCompilerPass, InjectableCompilerPass $injectableCompilerPass) { $generatorConfig->addCompilerPass($configCompilerPass)->shouldBeCalledTimes(1); $generatorConfig->addCompilerPass($injectableCompilerPass)->shouldBeCalledTimes(1); $container = $this->getContainer(); $this->getContainer()->shouldBe($container); }
/** * @return Container */ private function _buildContainer() { $this->_generatorConfig->addCompilerPass($this->_storeConfigCompilerPass); $this->_generatorConfig->addCompilerPass($this->_injectableCompilerPass); $this->_mageApp->dispatchEvent('symfony_container_before_container_generator', ['generator_config' => $this->_generatorConfig]); $generator = new ContainerGenerator($this->_generatorConfig); return $this->_container = $generator->getContainer(); }
function it_memoizes_the_container(MageApp $app, Configuration $generatorConfig, StoreConfigCompilerPass $configCompilerPass, InjectableCompilerPass $injectableCompilerPass) { $generatorConfig->addCompilerPass($configCompilerPass)->shouldBeCalledTimes(1); $generatorConfig->addCompilerPass($injectableCompilerPass)->shouldBeCalledTimes(1); $app->dispatchEvent('symfony_container_before_container_generator', ['generator_config' => $generatorConfig])->shouldBeCalled(); $container = $this->getContainer(); $this->getContainer()->shouldBe($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(Loader $loader, ContainerLoader $containerLoader, Filesystem $filesystem, ContainerBuilder $containerBuilder, Configuration $configuration) { $configuration->getServicesFormat()->willReturn('xml'); $configuration->getServicesFolders()->willReturn([]); $configuration->getContainerFilePath()->willReturn($this->containerFile); $configuration->getCompilerPasses()->willReturn([]); $containerLoader->loadFrom($this->containerFile)->willReturn($containerBuilder); $this->beConstructedWith($loader, $containerLoader, $filesystem); }
function it_skips_loading_test_services_if_none_exist(Configuration $configuration, ContainerBuilder $containerBuilder, DelegatingLoaderFactory $delegatingLoaderFactory, DelegatingLoader $delegatingLoader, Filesystem $filesystem) { $configuration->getServicesFolders()->willReturn(['etc1']); $configuration->isTestEnvironment()->willReturn(true); $delegatingLoaderFactory->create($containerBuilder, 'etc1')->willReturn($delegatingLoader); $filesystem->exists('etc1/services.xml')->willReturn(true); $filesystem->exists('etc1/services_test.xml')->willReturn(false); $this->loadContainer($configuration)->shouldReturnAnInstanceOf(Container::class); $delegatingLoader->load('services.xml')->shouldHaveBeenCalled(); $delegatingLoader->load('services_test.xml')->shouldNotHaveBeenCalled(); }
/** * @return Configuration */ public function build() { $servicesFormat = 'xml'; $cachedContainer = $this->_baseDir . '/' . self::CACHED_CONTAINER; $configuration = Configuration::fromParameters($cachedContainer, $this->_collectConfigFolders(), !$this->_mageApp->useCache(self::MODEL_ALIAS), $servicesFormat); $configuration->setTestEnvironment($this->_isTestEnvironment()); return $configuration; }
/** * @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; }
/** * @Given I have configured different services in both :folder1 and :folder2 */ public function iHaveConfiguredServicesInBothAnd($folder1, $folder2) { $folder1 = 'features/' . $folder1; $folder2 = 'features/' . $folder2; $this->configuration = Configuration::fromParameters($this->cachedContainerFile, [$folder1, $folder2], true, 'xml'); }
/** * @param Configuration $configuration */ public function configure(Configuration $configuration) { $this->serviceConfigs = $configuration->getServicesFolders(); $this->servicesFormat = $configuration->getServicesFormat(); $this->isTestEnvironment = $configuration->isTestEnvironment(); }
function it_memoizes_container(Configuration $generatorConfig) { $generatorConfig->addCompilerPass(Argument::any())->shouldBeCalledTimes(1); $container = $this->getContainer(); $this->getContainer()->shouldBe($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); }
/** * @return Container */ private function _buildContainer() { $this->_generatorConfig->addCompilerPass(new Inviqa_SymfonyContainer_Model_ExampleCompilerPass()); $generator = new ContainerGenerator($this->_generatorConfig); return $this->_container = $generator->getContainer(); }
<?php require_once 'vendor/autoload.php'; use ContainerTools\ContainerGenerator; use ContainerTools\Configuration; $configFolders = preg_split('/,/', $argv[1]); $isDebug = $argv[2] == 'true'; $isTest = $argv[3] == 'true'; $config = Configuration::fromParameters('./container.cache.php', $configFolders, $isDebug, 'xml'); $config->setTestEnvironment($isTest); $container = new ContainerGenerator($config); $container->getContainer(); include_once 'container.cache.php'; $container = new ProjectServiceContainer(); file_put_contents('serialized.container', serialize($container->getServiceIds()));