本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerBuilder::setProxyInstantiator方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerBuilder::setProxyInstantiator方法的具体用法?PHP ContainerBuilder::setProxyInstantiator怎么用?PHP ContainerBuilder::setProxyInstantiator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\DependencyInjection\ContainerBuilder
的用法示例。
在下文中一共展示了ContainerBuilder::setProxyInstantiator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildFromConfiguration
/**
* @param string $path path to grumphp.yml
*
* @return ContainerBuilder
*/
public static function buildFromConfiguration($path)
{
$container = new ContainerBuilder();
$container->setProxyInstantiator(new RuntimeInstantiator());
// Add compiler passes:
$container->addCompilerPass(new Compiler\ExtensionCompilerPass());
$container->addCompilerPass(new Compiler\PhpParserCompilerPass());
$container->addCompilerPass(new Compiler\TaskCompilerPass());
$container->addCompilerPass(new RegisterListenersPass('event_dispatcher', 'grumphp.event_listener', 'grumphp.event_subscriber'));
// Load basic service file + custom user configuration
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../../resources/config'));
$loader->load('formatter.yml');
$loader->load('linters.yml');
$loader->load('parameters.yml');
$loader->load('parsers.yml');
$loader->load('services.yml');
$loader->load('subscribers.yml');
$loader->load('tasks.yml');
$loader->load('util.yml');
// Load grumphp.yml file:
$filesystem = new Filesystem();
if ($filesystem->exists($path)) {
$loader->load($path);
}
// Compile configuration to make sure that tasks are added to the taskrunner
$container->compile();
return $container;
}
示例2: testCreateProxyServiceWithRuntimeInstantiator
public function testCreateProxyServiceWithRuntimeInstantiator()
{
$builder = new ContainerBuilder();
$builder->setProxyInstantiator(new RuntimeInstantiator());
$builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__ . '/Fixtures/includes/foo.php');
$builder->getDefinition('foo1')->setLazy(true);
/* @var $foo1 \ProxyManager\Proxy\LazyLoadingInterface|\ProxyManager\Proxy\ValueHolderInterface */
$foo1 = $builder->get('foo1');
$this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls');
$this->assertInstanceOf('\\ProxyManagerBridgeFooClass', $foo1);
$this->assertInstanceOf('\\ProxyManager\\Proxy\\LazyLoadingInterface', $foo1);
$this->assertFalse($foo1->isProxyInitialized());
$foo1->initializeProxy();
$this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved after initialization');
$this->assertTrue($foo1->isProxyInitialized());
$this->assertInstanceOf('\\ProxyManagerBridgeFooClass', $foo1->getWrappedValueHolderValue());
$this->assertNotInstanceOf('\\ProxyManager\\Proxy\\LazyLoadingInterface', $foo1->getWrappedValueHolderValue());
}
示例3: getContainerBuilder
/**
* Gets a new ContainerBuilder instance used to build the service container.
*
* @return ContainerBuilder
*/
protected function getContainerBuilder()
{
$container = new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
if (class_exists('ProxyManager\Configuration')) {
$container->setProxyInstantiator(new RuntimeInstantiator());
}
return $container;
}
示例4: enableLazyServicesSupport
/**
* @param ContainerBuilder $container
*/
private function enableLazyServicesSupport(ContainerBuilder $container)
{
$container->setProxyInstantiator(new RuntimeInstantiator());
}
示例5: getContainerBuilder
/**
* {@inheritdoc}
*/
protected function getContainerBuilder()
{
$container = new ContainerBuilder(new DrupalParameterBag($this->getKernelParameters()));
$container->setParameter('kernel.drupal_site_path', DRUPAL_ROOT . '/' . conf_path());
if (class_exists('ProxyManager\\Configuration') && class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\Instantiator\\RuntimeInstantiator')) {
$container->setProxyInstantiator(new RuntimeInstantiator());
}
return $container;
}
示例6: getContainerBuilder
/**
* Gets a new ContainerBuilder instance used to build the service container.
*
* @return ContainerBuilder
*/
protected function getContainerBuilder()
{
$container = new ContainerBuilder();
$container->getParameterBag()->add($this->getKernelParameters());
if (class_exists('ProxyManager\\Configuration') && class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\Instantiator\\RuntimeInstantiator')) {
$container->setProxyInstantiator(new RuntimeInstantiator());
}
return $container;
}
示例7: create_container
/**
* Create the ContainerBuilder object
*
* @param array $extensions Array of Container extension objects
* @return ContainerBuilder object
*/
protected function create_container(array $extensions)
{
$container = new ContainerBuilder(new ParameterBag($this->get_core_parameters()));
$container->setProxyInstantiator(new RuntimeInstantiator());
$extensions_alias = array();
foreach ($extensions as $extension) {
$container->registerExtension($extension);
$extensions_alias[] = $extension->getAlias();
}
$container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions_alias));
return $container;
}