當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。