當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhpDumper::setProxyDumper方法代碼示例

本文整理匯總了PHP中Symfony\Component\DependencyInjection\Dumper\PhpDumper::setProxyDumper方法的典型用法代碼示例。如果您正苦於以下問題:PHP PhpDumper::setProxyDumper方法的具體用法?PHP PhpDumper::setProxyDumper怎麽用?PHP PhpDumper::setProxyDumper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DependencyInjection\Dumper\PhpDumper的用法示例。


在下文中一共展示了PhpDumper::setProxyDumper方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDumper

 protected function getDumper(SymfonyBuilder $container) : DumperInterface
 {
     $dumper = new PhpDumper($container);
     if (class_exists(ProxyDumper::class)) {
         $dumper->setProxyDumper(new ProxyDumper());
     }
     return $dumper;
 }
開發者ID:lcobucci,項目名稱:di-builder,代碼行數:8,代碼來源:Compiler.php

示例2: testDumpContainerWithProxyService

 public function testDumpContainerWithProxyService()
 {
     $container = new ContainerBuilder();
     $container->register('foo', 'stdClass');
     $container->getDefinition('foo')->setLazy(true);
     $container->compile();
     $dumper = new PhpDumper($container);
     $dumper->setProxyDumper(new ProxyDumper());
     $dumpedString = $dumper->dump();
     $this->assertStringMatchesFormatFile(__DIR__ . '/../Fixtures/php/lazy_service_structure.txt', $dumpedString, '->dump() does generate proxy lazy loading logic.');
 }
開發者ID:BusinessCookies,項目名稱:CoffeeMachineProject,代碼行數:11,代碼來源:PhpDumperTest.php

示例3: dumpContainer

 /**
  * @param ContainerBuilder $container
  */
 protected function dumpContainer(ContainerBuilder $container)
 {
     $debug = $container->getParameter('debug');
     $randomId = mt_rand();
     $className = sprintf('dic_%d', $randomId);
     $containerFile = ROOT . 'cache/dic.php';
     $versionFile = ROOT . 'cache/dic.txt';
     $configFile = ROOT . 'cache/config.json';
     $dumper = new PhpDumper($container);
     $dumper->setProxyDumper(new ProxyDumper());
     $containerContent = $dumper->dump(['class' => $className, 'debug' => $debug]);
     file_put_contents($containerFile, $containerContent);
     file_put_contents($versionFile, $className);
     file_put_contents($configFile, json_encode($container->getParameterBag()->all(), JSON_PRETTY_PRINT));
     @chmod($containerFile, 0777);
     @chmod($versionFile, 0777);
     @chmod($configFile, 0777);
 }
開發者ID:brainexe,項目名稱:core,代碼行數:21,代碼來源:Rebuild.php

示例4: dumpContainer

    /**
     * Dumps the service container to PHP code in the cache.
     *
     * @param ConfigCache      $cache     The config cache
     * @param ContainerBuilder $container The service container
     * @param string           $class     The name of the class to generate
     * @param string           $baseClass The name of the container's base class
     */
    protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
    {
        // cache the container
        $dumper = new PhpDumper($container);

        if (class_exists('ProxyManager\Configuration')) {
            $dumper->setProxyDumper(new ProxyDumper());
        }

        $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
        if (!$this->debug) {
            $content = static::stripComments($content);
        }

        $cache->write($content, $container->getResources());
    }
開發者ID:hendryguna,項目名稱:laravel-basic,代碼行數:24,代碼來源:Kernel.php

示例5: dumpDrupalContainer

 /**
  * Dumps the service container to PHP code in the config directory.
  *
  * This method is based on the dumpContainer method in the parent class, but
  * that method is reliant on the Config component which we do not use here.
  *
  * @param ContainerBuilder $container
  *   The service container.
  * @param string $baseClass
  *   The name of the container's base class
  *
  * @return bool
  *   TRUE if the container was successfully dumped to disk.
  */
 protected function dumpDrupalContainer(ContainerBuilder $container, $baseClass)
 {
     if (!$this->storage()->writeable()) {
         return FALSE;
     }
     // Cache the container.
     $dumper = new PhpDumper($container);
     $dumper->setProxyDumper(new ProxyDumper(new ProxyBuilder()));
     $class = $this->getClassName();
     $namespace = $this->getClassNamespace();
     $content = $dumper->dump(['class' => $class, 'base_class' => $baseClass, 'namespace' => $namespace]);
     return $this->storage()->save($class . '.php', $content);
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:27,代碼來源:DrupalKernel.php

示例6: dumpContainer

 /**
  * {@inheritdoc}
  */
 protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
 {
     // cache the container
     $dumper = new PhpDumper($container);
     if ($container->getParameter('installed') && class_exists('ProxyManager\\Configuration') && class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\PhpDumper\\ProxyDumper')) {
         $dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
     }
     $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath()));
     if (!$this->debug) {
         $content = static::stripComments($content);
     }
     $cache->write($content, $container->getResources());
 }
開發者ID:antrampa,項目名稱:platform,代碼行數:16,代碼來源:OroKernel.php

示例7: dumpContainer

 /**
  * {@inheritdoc}
  */
 protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
 {
     // cache the container
     $dumper = new PhpDumper($container);
     if ($container->getParameter('installed') && class_exists('ProxyManager\\Configuration')) {
         $dumper->setProxyDumper(new ProxyDumper());
     }
     $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass));
     $cache->write($content, $container->getResources());
     if (!$this->debug) {
         $cache->write(php_strip_whitespace($cache), $container->getResources());
     }
 }
開發者ID:northdakota,項目名稱:platform,代碼行數:16,代碼來源:OroKernel.php

示例8: dumpContainer

    /**
     * Dumps the service container to PHP code in the cache.
     *
     * @param ConfigCache      $cache     The config cache
     * @param ContainerBuilder $container The service container
     * @param string           $class     The name of the class to generate
     * @param string           $baseClass The name of the container's base class
     */
    protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
    {
        // cache the container
        $dumper = new PhpDumper($container);

        if (class_exists('ProxyManager\Configuration') && class_exists('Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper')) {
            $dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
        }

        $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath(), 'debug' => $this->debug));

        $cache->write($content, $container->getResources());
    }
開發者ID:nwdrupal,項目名稱:nwdrupalwebsite,代碼行數:21,代碼來源:Kernel.php

示例9: dumpContainer

 /**
  * Dumps the service container to PHP code in the cache
  *
  * @param \Symfony\Component\Config\ConfigCache $cache
  */
 protected function dumpContainer(ConfigCache $cache)
 {
     $dumper = new PhpDumper($this->innerContainer);
     if (class_exists('ProxyManager\\Configuration')) {
         $dumper->setProxyDumper(new ProxyDumper());
     }
     $content = $dumper->dump(array('class' => $this->containerClassName, 'base_class' => "Container"));
     $cache->write($content, $this->innerContainer->getResources());
 }
開發者ID:brookinsconsulting,項目名稱:ezecosystem,代碼行數:14,代碼來源:ServiceContainer.php

示例10: dump_container

 /**
  * Dump the container to the disk.
  *
  * @param ConfigCache $cache The config cache
  */
 protected function dump_container($cache)
 {
     try {
         $dumper = new PhpDumper($this->container);
         $proxy_dumper = new ProxyDumper();
         $dumper->setProxyDumper($proxy_dumper);
         $cached_container_dump = $dumper->dump(array('class' => 'phpbb_cache_container', 'base_class' => 'Symfony\\Component\\DependencyInjection\\ContainerBuilder'));
         $cache->write($cached_container_dump, $this->container->getResources());
     } catch (IOException $e) {
         // Don't fail if the cache isn't writeable
     }
 }
開發者ID:phpbb,項目名稱:phpbb-core,代碼行數:17,代碼來源:container_builder.php

示例11: dumpContainer

 /**
  * {@inheritdoc}
  */
 protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
 {
     // cache the container
     $dumper = new PhpDumper($container);
     if ($container->getParameter('installed') && class_exists('ProxyManager\\Configuration') && class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\PhpDumper\\ProxyDumper')) {
         $dumper->setProxyDumper(new ProxyDumper(md5($cache->getPath())));
     }
     $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'file' => $cache->getPath()));
     $cache->write($content, $container->getResources());
     // we should not use parent::stripComments method to cleanup source code from the comments to avoid
     // memory leaks what generate token_get_all function.
     if (!$this->debug) {
         $cache->write(php_strip_whitespace($cache->getPath()), $container->getResources());
     }
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:18,代碼來源:OroKernel.php

示例12: dumpContainer

 /**
  * @param \Heystack\Core\DependencyInjection\SilverStripe\HeystackSilverStripeContainerBuilder $container
  * @param stirng $mode
  * @param bool|void $debug
  * @return string
  */
 protected function dumpContainer(HeystackSilverStripeContainerBuilder $container, $mode, $debug = false)
 {
     $container->compile();
     if ($debug) {
         $dumper = new YamlDumper($container);
         return $dumper->dump();
     } else {
         $location = $this->heystackBasePath . '/cache/';
         if (!file_exists($location)) {
             mkdir($location, 0777, true);
         }
         $class = "HeystackServiceContainer{$mode}";
         $dumper = new PhpDumper($container);
         if (class_exists('Symfony\\Bridge\\ProxyManager\\LazyProxy\\PhpDumper\\ProxyDumper')) {
             $dumper->setProxyDumper(new ProxyDumper());
         }
         file_put_contents($this->getRealPath($location) . "/{$class}.php", $dumper->dump(['class' => $class, 'base_class' => "Heystack\\Core\\DependencyInjection\\SilverStripe\\HeystackSilverStripeContainer"]));
         return 'Container generated';
     }
 }
開發者ID:helpfulrobot,項目名稱:heystack-heystack,代碼行數:26,代碼來源:GenerateContainer.php

示例13: testCircularReferenceAllowanceForInlinedDefinitionsForLazyServices

    public function testCircularReferenceAllowanceForInlinedDefinitionsForLazyServices()
    {
        /*
         *   test graph:
         *              [connection] -> [event_manager] --> [entity_manager](lazy)
         *                                                           |
         *                                                           --(call)- addEventListener ("@lazy_service")
         *
         *              [lazy_service](lazy) -> [entity_manager](lazy)
         *
         */

        $container = new ContainerBuilder();

        $eventManagerDefinition = new Definition('stdClass');

        $connectionDefinition = $container->register('connection', 'stdClass');
        $connectionDefinition->addArgument($eventManagerDefinition);

        $container->register('entity_manager', 'stdClass')
            ->setLazy(true)
            ->addArgument(new Reference('connection'));

        $lazyServiceDefinition = $container->register('lazy_service', 'stdClass');
        $lazyServiceDefinition->setLazy(true);
        $lazyServiceDefinition->addArgument(new Reference('entity_manager'));

        $eventManagerDefinition->addMethodCall('addEventListener', array(new Reference('lazy_service')));

        $container->compile();

        $dumper = new PhpDumper($container);

        $dumper->setProxyDumper(new DummyProxyDumper());
        $dumper->dump();
    }
開發者ID:symfony,項目名稱:symfony,代碼行數:36,代碼來源:PhpDumperTest.php


注:本文中的Symfony\Component\DependencyInjection\Dumper\PhpDumper::setProxyDumper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。