本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::getCompilerPassConfig方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::getCompilerPassConfig方法的具体用法?PHP ContainerBuilder::getCompilerPassConfig怎么用?PHP ContainerBuilder::getCompilerPassConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::getCompilerPassConfig方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContainer
protected function getContainer()
{
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config'));
$loader->load('monolog.xml');
$definition = $container->getDefinition('monolog.logger_prototype');
$container->set('monolog.handler.test', new Definition('%monolog.handler.null.class%', array(100, false)));
$definition->addMethodCall('pushHandler', array(new Reference('monolog.handler.test')));
// Handlers
$container->set('monolog.handler.a', new Definition('%monolog.handler.null.class%', array(100, false)));
$container->set('monolog.handler.b', new Definition('%monolog.handler.null.class%', array(100, false)));
$container->set('monolog.handler.c', new Definition('%monolog.handler.null.class%', array(100, false)));
// Channels
foreach (array('test', 'foo', 'bar') as $name) {
$service = new Definition('TestClass', array('false', new Reference('logger')));
$service->addTag('monolog.logger', array('channel' => $name));
$container->setDefinition($name, $service);
}
$container->setParameter('monolog.handlers_to_channels', array('monolog.handler.a' => array('type' => 'inclusive', 'elements' => array('test')), 'monolog.handler.b' => null, 'monolog.handler.c' => array('type' => 'exclusive', 'elements' => array('foo'))));
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->addCompilerPass(new LoggerChannelPass());
$container->compile();
return $container;
}
示例2: compileContainer
protected function compileContainer(ContainerBuilder $container)
{
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->addCompilerPass(new CryptorInjectorPass());
$container->compile();
return $container;
}
示例3: testProcessorPass
public function testProcessorPass()
{
$compilerPasses = $this->container->getCompilerPassConfig()->getPasses();
$processorPasses = array_filter($compilerPasses, function (CompilerPassInterface $compilerPass) {
return $compilerPass instanceof ProcessorsPass;
});
$this->assertCount(1, $processorPasses);
}
示例4: testCompilerPassIsRegistered
public function testCompilerPassIsRegistered()
{
$bundle = new BernardBundle();
$bundle->build($this->container);
$passes = $this->container->getCompilerPassConfig()->getBeforeOptimizationPasses();
$this->assertCount(2, $passes);
$this->assertInstanceOf('Bernard\\BernardBundle\\DependencyInjection\\Compiler\\ReceiverPass', $passes[0]);
$this->assertInstanceOf('Bernard\\BernardBundle\\DependencyInjection\\Compiler\\NormalizerPass', $passes[1]);
}
示例5: loadsTheExtension
/**
* @test
*/
public function loadsTheExtension()
{
$container = new ContainerBuilder();
$container->registerExtension(new PieceQuestetraExtension());
$container->loadFromExtension('piece_questetra', array('context_root' => 'https://www.example.com/01234567', 'authentication' => array('user_id' => 'foo@example.com', 'password' => 'u7K1TzgUFcvOG0Ui')));
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
$this->assertTrue($container->has('piece_questetra.questetra_client'));
}
示例6: getContainer
private function getContainer($file)
{
$container = new ContainerBuilder();
$container->registerExtension(new JuSimpleSearchExtension());
$fileLocator = new FileLocator(__DIR__ . '/Fixtures');
$loader = new YamlFileLoader($container, $fileLocator);
$loader->load($file);
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
return $container;
}
示例7: getContainer
private function getContainer($file, $debug = false)
{
$container = new ContainerBuilder(new ParameterBag(array('kernel.debug' => $debug)));
$container->registerExtension(new VilksFileSearchExtension());
$locator = new FileLocator(__DIR__ . '/Fixtures');
$loader = new YamlFileLoader($container, $locator);
$loader->load($file);
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
return $container;
}
示例8: compile
public function compile()
{
/**
* @var $pass tubepress_spi_ioc_CompilerPassInterface
*/
foreach ($this->_tubePressCompilerPasses as $pass) {
$pass->process($this);
}
$compilerConfig = $this->_delegateContainerBuilder->getCompilerPassConfig();
$compilerConfig->setRemovingPasses(array(new \Symfony\Component\DependencyInjection\Compiler\RemovePrivateAliasesPass(), new \Symfony\Component\DependencyInjection\Compiler\RemoveAbstractDefinitionsPass(), new \Symfony\Component\DependencyInjection\Compiler\ReplaceAliasByActualDefinitionPass(), new \Symfony\Component\DependencyInjection\Compiler\RepeatedPass(array(new \Symfony\Component\DependencyInjection\Compiler\AnalyzeServiceReferencesPass(), new \Symfony\Component\DependencyInjection\Compiler\RemoveUnusedDefinitionsPass())), new \Symfony\Component\DependencyInjection\Compiler\CheckExceptionOnInvalidReferenceBehaviorPass()));
$this->_delegateContainerBuilder->compile();
}
示例9: getContainer
private function getContainer($file, $parameters = [], $debug = false)
{
$container = new ContainerBuilder(new ParameterBag(array_merge($parameters, ['kernel.debug' => $debug])));
$container->registerExtension(new TreeHouseBaseApiExtension());
$locator = new FileLocator(__DIR__ . '/../Fixtures');
$loader = new YamlFileLoader($container, $locator);
$loader->load($file);
$container->getCompilerPassConfig()->setOptimizationPasses([]);
$container->getCompilerPassConfig()->setRemovingPasses([]);
$container->compile();
return $container;
}
示例10: loadContainerFromFile
/**
* @param string $file
*
* @return ContainerBuilder
*/
private function loadContainerFromFile($file)
{
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
$container->setParameter('kernel.cache_dir', '/tmp');
$container->registerExtension(new OpenOrchestraMediaModelExtension());
$locator = new FileLocator(__DIR__ . '/Fixtures/config/');
$loader = new YamlFileLoader($container, $locator);
$loader->load($file . '.yml');
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
return $container;
}
开发者ID:itkg-canne,项目名称:open-orchestra-media-bundle,代码行数:19,代码来源:OpenOrchestraMediaModelExtensionTest.php
示例11: build
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
$passConfig = $container->getCompilerPassConfig();
$passConfig->addPass(new AnnotationConfigurationPass($this->kernel));
$passConfig->addPass(new ServiceConfigurationPass());
$container->addCompilerPass(new GlobalTaggedServicesPass());
}
示例12: prependBeforeOptimizationPass
public static function prependBeforeOptimizationPass(ContainerBuilder $container, CompilerPassInterface $compilerPass)
{
$compilerPassConfig = $container->getCompilerPassConfig();
$beforeOptimizationPasses = $compilerPassConfig->getBeforeOptimizationPasses();
array_unshift($beforeOptimizationPasses, $compilerPass);
$compilerPassConfig->setBeforeOptimizationPasses($beforeOptimizationPasses);
}
示例13: getContainer
protected function getContainer()
{
$container = new ContainerBuilder();
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../../../Resources/config'));
$loader->load('monolog.xml');
$definition = $container->getDefinition('monolog.logger_prototype');
$container->set('monolog.handler.test', new Definition('%monolog.handler.null.class%', array(100, false)));
$definition->addMethodCall('pushHandler', array(new Reference('monolog.handler.test')));
$service = new Definition('TestClass', array('false', new Reference('logger')));
$service->addTag('monolog.logger', array('channel' => 'test'));
$container->setDefinition('test', $service);
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->addCompilerPass(new LoggerChannelPass());
$container->compile();
return $container;
}
示例14: loadExtension
private function loadExtension(array $config, $compile = true)
{
$config = array_merge(['transports' => ['amqp' => []]], $config);
$this->extension->load(['event_band' => $config], $this->container);
$this->container->getCompilerPassConfig()->setRemovingPasses(array());
if ($compile) {
$this->container->compile();
}
}
示例15: registersMappingFilesInTheSpecifiedDirectories
/**
* @test
*/
public function registersMappingFilesInTheSpecifiedDirectories()
{
$container = new ContainerBuilder(new ParameterBag(array('kernel.debug' => false, 'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle', 'PieceValidationDirectoryLoaderBundle' => 'Piece\\Bundle\\ValidationDirectoryLoaderBundle\\PieceValidationDirectoryLoaderBundle'), 'kernel.cache_dir' => __DIR__)));
$container->registerExtension(new FrameworkExtension());
$container->registerExtension(new PieceValidationDirectoryLoaderExtension());
$container->loadFromExtension('framework', array('secret' => '154F520832A9BC66316C259EEC70E4FA671A12F5', 'validation' => array('enable_annotations' => false)));
$container->loadFromExtension('piece_validationdirectoryloader', array('mapping_dirs' => array(__DIR__ . '/Fixtures/validation/a', __DIR__ . '/Fixtures/validation/b')));
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
foreach (array(new Foo(), new Bar(), new Baz()) as $entity) {
$violations = $container->get('validator')->validate($entity);
$this->assertEquals(1, count($violations));
$this->assertSame($entity, $violations[0]->getRoot());
$entityClass = new \ReflectionObject($entity);
$this->assertEquals(strtolower($entityClass->getShortName()), $violations[0]->getPropertyPath());
}
}
开发者ID:piece,项目名称:piece-validationdirectoryloader-bundle,代码行数:21,代码来源:PieceValidationDirectoryLoaderExtensionTest.php