本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::compile方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::compile方法的具体用法?PHP ContainerBuilder::compile怎么用?PHP ContainerBuilder::compile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::compile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* @param null $configPath
* @param array $configFilenames
*/
function __construct($configPath = null, $configFilenames = array())
{
$configPath = $configPath == null ? __DIR__ . '/../../../../../../app/config' : $configPath;
$this->container = new ContainerBuilder();
// Load app parameters and config files into container
$loader = new YamlFileLoader($this->container, new FileLocator($configPath));
$loader->load('parameters.yml');
foreach ($configFilenames as $filename) {
$loader->load($filename);
}
$appName = $this->container->getParameter('application_name');
$appVersion = $this->container->getParameter('application_version');
parent::__construct($appName, $appVersion);
// Set dispatcher definition, register listeners and subscribers
$dispatcherDef = $this->container->register('event_dispatcher', 'Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher');
$dispatcherDef->addArgument($this->container);
$this->registerEventListeners();
$this->container->compile();
// Once container is compiled we can get the event_dispatcher from dic
$this->dispatcher = $this->container->get('event_dispatcher');
// Add console commands (services console.command tagged)
foreach ($this->getTaggedCommands() as $id) {
$command = $this->container->get($id);
$this->add($command);
}
}
示例2: testTemplatingConfiguration
public function testTemplatingConfiguration()
{
$this->loadConfiguration($this->container, 'simple');
$this->container->compile();
$helper = $this->container->get('fm_tinymce.templating.helper');
$this->assertInstanceOf('FM\\TinyMCEBundle\\Templating\\TinyMCEHelper', $helper);
}
示例3: testReconnectConfiguration
public function testReconnectConfiguration()
{
$this->initContainer();
$this->loadConfiguration($this->container, 'reconnect_config');
$this->container->compile();
$this->assert->boolean($this->container->has('m6_redis'))->isIdenticalTo(true)->and()->object($serviceRedis = $this->container->get('m6_redis'))->isInstanceOf('M6Web\\Bundle\\RedisBundle\\Redis\\Redis');
}
示例4: build
/**
* Builds the container.
* @param array $parameters
*/
public function build($parameters = array())
{
// sort array by key to generate the container name
ksort($parameters);
// needed for new packages installed
$composerClass = array_filter(get_declared_classes(), function ($item) {
if (0 === strpos($item, 'ComposerAutoloaderInit')) {
return true;
}
});
$composerClass = array_pop($composerClass);
// generate hash
$parametersHash = md5(serialize($parameters) . $composerClass);
$containerClass = 'Container' . $parametersHash;
$isDebug = true;
$file = sprintf('%s/ladybug_cache/%s.php', sys_get_temp_dir(), $parametersHash);
$containerConfigCache = new ConfigCache($file, $isDebug);
if (!$containerConfigCache->isFresh()) {
$this->initializeContainer();
$this->loadServices();
$this->loadThemes();
$this->loadPlugins();
$this->setParameters($parameters);
$this->container->compile();
$dumper = new PhpDumper($this->container);
$containerConfigCache->write($dumper->dump(array('class' => $containerClass)), $this->container->getResources());
} else {
require_once $file;
$this->container = new $containerClass();
}
}
示例5: testLoadExtension
/**
* Test load extension
* @throws \LogicException
* @throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
*/
public function testLoadExtension()
{
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
// Check that services have been loaded
static::assertTrue($this->container->has('timestamp.type'));
}
示例6: compile
/**
* @return SymfonyContainerBuilder
*/
public function compile()
{
$this->registerServices($this->parameters['services']);
$this->builder->setResourceTracking(false);
$this->builder->compile();
return $this->builder;
}
示例7: boot
protected function boot()
{
if ($this->hasBooted()) {
return;
}
// Nothing to do
if ($this->debug) {
$this->setContainer(new ContainerBuilder(new ParameterBag($this->getAppParameters())));
$this->loadContainerConfiguration();
} else {
$filename = $this->getContainerCacheFilename();
if (file_exists($filename)) {
require_once $filename;
$this->setContainer(new CachedContainer());
} else {
$this->setContainer(new ContainerBuilder(new ParameterBag($this->getAppParameters())));
$this->loadContainerConfiguration();
$this->container->compile();
if ($this->containerIsCacheable()) {
$dumper = new PhpDumper($this->container);
file_put_contents($filename, $dumper->dump());
}
}
}
}
示例8: testIfAServiceDefinitionIsNotCorrectAnExceptionWillBeThrown
public function testIfAServiceDefinitionIsNotCorrectAnExceptionWillBeThrown()
{
$loader = new XmlFileLoader($this->container, new FileLocator(__DIR__ . '/Fixtures'));
$loader->load('incorrect_service_definitions.xml');
$this->setExpectedException('Matthias\\SymfonyServiceDefinitionValidator\\Exception\\InvalidServiceDefinitionsException');
$this->container->compile();
}
示例9: testDefaultConfiguration
public function testDefaultConfiguration()
{
// An extension is only loaded in the container if a configuration is provided for it.
// Then, we need to explicitely load it.
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
$this->assertTrue($this->container->getParameterBag()->has('gg_team_breadcrumb'));
}
示例10: it_gets_cleaners
/**
* @test
*/
public function it_gets_cleaners()
{
$this->createCleaner('cleaner1');
$this->createCleaner('cleaner2');
$this->createCleaner('cleaner3');
$this->container->compile();
$this->resolverContainsCleaners(array('cleaner1', 'cleaner2', 'cleaner3'));
}
示例11: it_gets_fingers_crossed_handlers
/**
* @test
*/
public function it_gets_fingers_crossed_handlers()
{
$this->createFingersCrossedHandler('monolog.handler.handler1');
$this->createFingersCrossedHandler('monolog.handler.handler2');
$this->createFingersCrossedHandler('monolog.handler.handler3');
$this->container->compile();
$this->resolverContainsFingersCrossedHandlers(array('monolog.handler.handler1', 'monolog.handler.handler2', 'monolog.handler.handler3'));
}
示例12: __construct
public function __construct()
{
$this->container = new ContainerBuilder();
$this->container->addCompilerPass(new CommandBusCompilerPass());
$this->container->addCompilerPass(new QueryBusCompilerPass());
$this->getConfigServices();
$this->container->compile();
}
示例13: testLoadExtension
/**
* Test load extension
*/
public function testLoadExtension()
{
$this->container->prependExtensionConfig($this->extension->getAlias(), ['login' => 'XXX']);
$this->container->loadFromExtension($this->extension->getAlias());
$this->container->compile();
// Check that services have been loaded
$this->assertTrue($this->container->has('hellosign.client'));
}
示例14: testSharedService
public function testSharedService()
{
$this->loader->load(__DIR__ . '/Fixtures/sharedService.yml');
$this->container->compile();
$one = $this->container->get('foo');
$two = $this->container->get('foo');
$this->assertNotSame($one, $two);
}
示例15: it_configures_a_chain_of_buses_according_to_the_given_priorities
/**
* @test
*/
public function it_configures_a_chain_of_buses_according_to_the_given_priorities()
{
$this->createBusDefinition('middleware100', 100);
$this->createBusDefinition('middleware-100', -100);
$this->createBusDefinition('middleware200', 200);
$this->container->compile();
$this->commandBusContainsMiddlewares(array('middleware200', 'middleware100', 'middleware-100'));
}