当前位置: 首页>>代码示例>>PHP>>正文


PHP ContainerBuilder::setProxyInstantiator方法代码示例

本文整理汇总了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;
 }
开发者ID:phpro,项目名称:grumphp,代码行数:33,代码来源:ContainerFactory.php

示例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());
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:18,代码来源:ContainerBuilderTest.php

示例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;
    }
开发者ID:hendryguna,项目名称:laravel-basic,代码行数:15,代码来源:Kernel.php

示例4: enableLazyServicesSupport

 /**
  * @param ContainerBuilder $container
  */
 private function enableLazyServicesSupport(ContainerBuilder $container)
 {
     $container->setProxyInstantiator(new RuntimeInstantiator());
 }
开发者ID:Andretti23,项目名称:Sylius,代码行数:7,代码来源:MultiContainerExtension.php

示例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;
 }
开发者ID:makinacorpus,项目名称:drupal-sf-dic,代码行数:12,代码来源:Kernel.php

示例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;
 }
开发者ID:yceruto,项目名称:symfony,代码行数:14,代码来源:Kernel.php

示例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;
 }
开发者ID:phpbb,项目名称:phpbb-core,代码行数:18,代码来源:container_builder.php


注:本文中的Symfony\Component\DependencyInjection\ContainerBuilder::setProxyInstantiator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。