本文整理汇总了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;
}
示例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.');
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
}
示例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());
}
示例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());
}
示例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
}
}
示例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());
}
}
示例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';
}
}
示例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();
}