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


PHP PhpDumper::dump方法代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\Dumper\PhpDumper::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpDumper::dump方法的具体用法?PHP PhpDumper::dump怎么用?PHP PhpDumper::dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\DependencyInjection\Dumper\PhpDumper的用法示例。


在下文中一共展示了PhpDumper::dump方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build

 /**
  * Builds the container.
  * @param array $parameters
  */
 public function build($parameters = array())
 {
     // sort array by key to generate the container name
     ksort($parameters);
     // needed for new packages installed
     $composerClass = array_filter(get_declared_classes(), function ($item) {
         if (0 === strpos($item, 'ComposerAutoloaderInit')) {
             return true;
         }
     });
     $composerClass = array_pop($composerClass);
     // generate hash
     $parametersHash = md5(serialize($parameters) . $composerClass);
     $containerClass = 'Container' . $parametersHash;
     $isDebug = true;
     $file = sprintf('%s/ladybug_cache/%s.php', sys_get_temp_dir(), $parametersHash);
     $containerConfigCache = new ConfigCache($file, $isDebug);
     if (!$containerConfigCache->isFresh()) {
         $this->initializeContainer();
         $this->loadServices();
         $this->loadThemes();
         $this->loadPlugins();
         $this->setParameters($parameters);
         $this->container->compile();
         $dumper = new PhpDumper($this->container);
         $containerConfigCache->write($dumper->dump(array('class' => $containerClass)), $this->container->getResources());
     } else {
         require_once $file;
         $this->container = new $containerClass();
     }
 }
开发者ID:ankalagon,项目名称:ladybug,代码行数:35,代码来源:Application.php

示例2: warmup

 public static function warmup()
 {
     $containerFile = self::getCacheDir() . '/container.php';
     $builder = self::getContainer();
     $dumper = new PhpDumper($builder);
     file_put_contents($containerFile, $dumper->dump());
 }
开发者ID:phpbench,项目名称:benchmarks-containers,代码行数:7,代码来源:SymfonyDiBench.php

示例3: 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);
     $content = $dumper->dump(array('class' => $class, 'base_class' => $baseClass, 'optimize_strings' => false));
     $cache->write($content, $container->getResources());
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:15,代码来源:file.php

示例4: boot

 protected function boot()
 {
     if ($this->hasBooted()) {
         return;
     }
     // Nothing to do
     if ($this->debug) {
         $this->setContainer(new ContainerBuilder(new ParameterBag($this->getAppParameters())));
         $this->loadContainerConfiguration();
     } else {
         $filename = $this->getContainerCacheFilename();
         if (file_exists($filename)) {
             require_once $filename;
             $this->setContainer(new CachedContainer());
         } else {
             $this->setContainer(new ContainerBuilder(new ParameterBag($this->getAppParameters())));
             $this->loadContainerConfiguration();
             $this->container->compile();
             if ($this->containerIsCacheable()) {
                 $dumper = new PhpDumper($this->container);
                 file_put_contents($filename, $dumper->dump());
             }
         }
     }
 }
开发者ID:lastzero,项目名称:symlex-core,代码行数:25,代码来源:App.php

示例5: create

 /**
  * Loads a container and returns it.
  *
  * If the cache file for the service container exists and is current, it
  * will be loaded and returned. Otherwise, a new container will be built
  * using the configuration file and the provided optional builder. The
  * builder will be used to make changes to the service container before
  * it is compiled and cached.
  *
  * It may be important to note that debug mode for the `ConfigCache` class
  * is enabled by default. This will ensure that cached configuration files
  * are updated whenever they are changed.
  *
  * @param string   $containerCacheFilePath     The container cache file path.
  * @param callable $containerBuilderCallable   The new container builder callable.
  * @param string   $compiledContainerClassName The compiled container class name.
  * @param boolean  $debug                      Is debugging mode enabled?
  *
  * @return Jarvis The loaded application.
  */
 public static function create($containerCacheFilePath, callable $containerBuilderCallable = null, $compiledContainerClassName = 'AppCachedContainer', $debug = true)
 {
     $cacheManager = new ConfigCache($containerCacheFilePath, $debug);
     if (!$cacheManager->isFresh()) {
         $container = static::createContainer();
         if (null !== $containerBuilderCallable) {
             $containerBuilderCallable($container);
         }
         if ($debug) {
             $filename = pathinfo($containerCacheFilePath, PATHINFO_DIRNAME) . '/' . pathinfo($containerCacheFilePath, PATHINFO_FILENAME) . '.xml';
             $container->setParameter('debug.container.dump', $filename);
         }
         $container->compile();
         $dumper = new PhpDumper($container);
         $cacheManager->write($dumper->dump(array('class' => $compiledContainerClassName)), $container->getResources());
         if ($debug) {
             $filename = $container->getParameter('debug.container.dump');
             $dumper = new XmlDumper($container);
             $filesystem = new Filesystem();
             $filesystem->dumpFile($filename, $dumper->dump(), null);
             try {
                 $filesystem->chmod($filename, 0666, umask());
             } catch (IOException $e) {
                 // discard chmod failure (some filesystem may not support it)
             }
         }
     }
     if (!class_exists($compiledContainerClassName)) {
         /** @noinspection PhpIncludeInspection */
         require $containerCacheFilePath;
     }
     return new Jarvis(new $compiledContainerClassName());
 }
开发者ID:tonydub,项目名称:jarvis,代码行数:53,代码来源:JarvisFactory.php

示例6:

 function it_uses_container_dump_to_create_the_cache(Filesystem $filesystem, ContainerDumperFactory $dumperFactory, ContainerBuilder $containerBuilder, PhpDumper $dumper)
 {
     $dumper->dump()->willReturn('file contents');
     $dumperFactory->create($containerBuilder)->willReturn($dumper);
     $this->dump($containerBuilder);
     $filesystem->dumpFile($this->path, 'file contents')->shouldHaveBeenCalled();
 }
开发者ID:adrianoaguiar,项目名称:symfony-container-generator,代码行数:7,代码来源:FilesystemSpec.php

示例7: compile

 public function compile()
 {
     foreach (PluginRepository::findAll() as $plugin) {
         $containerBuilder = new UnfreezableContainerBuilder();
         $containerBuilder->registerExtension(new GeneralExtension());
         $extensionClass = new \ReflectionClass('Stagehand\\TestRunner\\DependencyInjection\\Extension\\' . $plugin->getPluginID() . 'Extension');
         if (!$extensionClass->isInterface() && !$extensionClass->isAbstract() && $extensionClass->isSubclassOf('Symfony\\Component\\DependencyInjection\\Extension\\ExtensionInterface')) {
             $containerBuilder->registerExtension($extensionClass->newInstance());
         }
         foreach ($containerBuilder->getExtensions() as $extension) {
             /* @var $extension \Symfony\Component\DependencyInjection\Extension\ExtensionInterface */
             $containerBuilder->loadFromExtension($extension->getAlias(), array());
         }
         $containerBuilder->addCompilerPass(new ReplaceDefinitionByPluginDefinitionPass($plugin));
         $containerBuilder->getCompilerPassConfig()->setOptimizationPasses(array_filter($containerBuilder->getCompilerPassConfig()->getOptimizationPasses(), function (CompilerPassInterface $compilerPass) {
             return !$compilerPass instanceof ResolveParameterPlaceHoldersPass;
         }));
         ErrorReporting::invokeWith(error_reporting() & ~E_USER_DEPRECATED, function () use($containerBuilder) {
             $containerBuilder->compile();
         });
         $phpDumper = new PhpDumper($containerBuilder);
         $containerClass = $plugin->getPluginID() . 'Container';
         $containerClassSource = $phpDumper->dump(array('class' => $containerClass));
         $containerClassSource = preg_replace('/^<\\?php/', '<?php' . PHP_EOL . 'namespace ' . self::COMPILED_CONTAINER_NAMESPACE . ';' . PHP_EOL, $containerClassSource);
         file_put_contents(__DIR__ . '/../' . $containerClass . '.php', $containerClassSource);
     }
 }
开发者ID:piece,项目名称:stagehand-testrunner,代码行数:27,代码来源:Compiler.php

示例8: buildContainer

 /**
  * @param BundleInterface[] $bundles
  * @param array             $configs
  * @param bool              $compile
  *
  * @return ContainerBuilder
  */
 protected function buildContainer(array $bundles = [], array $configs = [], $compile = true)
 {
     $container = new ContainerBuilder(new ParameterBag(['kernel.debug' => false, 'kernel.bundles' => array_map('get_class', $bundles), 'kernel.cache_dir' => CACHE_DIR . 'test', 'kernel.environment' => 'test', 'kernel.root_dir' => __DIR__]));
     $container->set('annotation_reader', new AnnotationReader());
     $container->addObjectResource($container);
     $extensions = [];
     foreach ($bundles as $bundle) {
         if ($extension = $bundle->getContainerExtension()) {
             $container->registerExtension($extension);
             $extensions[] = $extension->getAlias();
         }
         $container->addObjectResource($bundle);
     }
     foreach ($bundles as $bundle) {
         $bundle->build($container);
     }
     foreach ($configs as $alias => $config) {
         $container->prependExtensionConfig($alias, $config);
     }
     // ensure these extensions are implicitly loaded
     $container->getCompilerPassConfig()->setMergePass(new MergeExtensionConfigurationPass($extensions));
     foreach ($bundles as $bundle) {
         $bundle->setContainer($container);
         $bundle->boot();
     }
     $container->compile();
     $dumper = new PhpDumper($container);
     $dumper->dump();
     return $container;
 }
开发者ID:bankiru,项目名称:doctrine-api-bundle,代码行数:37,代码来源:ContainerTest.php

示例9:

 function it_uses_config_cache_to_create_the_cache(Filesystem $filesystem, ContainerDumperFactory $dumperFactory, ContainerBuilder $containerBuilder, PhpDumper $dumper, ConfigCache $configCache)
 {
     $dumper->dump()->willReturn('file contents');
     $dumperFactory->create($containerBuilder)->willReturn($dumper);
     $containerBuilder->getResources()->willReturn([]);
     $this->dump($containerBuilder);
     $configCache->write('file contents', [])->shouldHaveBeenCalled();
 }
开发者ID:inviqa,项目名称:symfony-container-generator,代码行数:8,代码来源:FilesystemSpec.php

示例10: dumpContainer

 /**
  * @param SymfonyRequest $symfonyRequest
  * @param string $filePath
  */
 private function dumpContainer(SymfonyRequest $symfonyRequest, $filePath)
 {
     $containerConfigCache = new ConfigCache($filePath, $this->appMode === ApplicationMode::DEVELOPMENT);
     if (!$containerConfigCache->isFresh()) {
         $containerBuilder = ServiceContainerBuilder::create($this->appPath, $symfonyRequest, $this->appMode);
         $dumper = new PhpDumper($containerBuilder);
         $containerConfigCache->write($dumper->dump(['class' => 'ACP3ServiceContainer']), $containerBuilder->getResources());
     }
 }
开发者ID:acp3,项目名称:core,代码行数:13,代码来源:Bootstrap.php

示例11: 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

示例12: dumpContainer

 protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, $class, $baseClass)
 {
     $dumper = new PhpDumper($container);
     $namespace = null;
     if (($p = strrpos($class, "\\")) !== false) {
         $namespace = substr($class, 0, $p);
         $class = substr($class, $p + 1);
     }
     $content = $dumper->dump(["namespace" => $namespace, "class" => $class, "base_class" => $baseClass]);
     $cache->write($content, $container->getResources());
 }
开发者ID:skrz,项目名称:stack,代码行数:11,代码来源:SkrzKernel.php

示例13: getContainer

 public function getContainer()
 {
     $container = new ContainerBuilder(new ParameterBag(array('kernel.bundle_dirs' => array(), 'kernel.bundles' => array(), 'kernel.cache_dir' => sys_get_temp_dir())));
     $loader = new DoctrineMongoDBExtension();
     $container->registerExtension($loader);
     $loader->mongodbLoad(array(), $container);
     $dumper = new PhpDumper($container);
     $code = $dumper->dump(array('class' => 'DoctrineMongoDBBundleTestsProjectServiceContainer'));
     eval(str_replace('<?php', null, $code));
     return new \DoctrineMongoDBBundleTestsProjectServiceContainer();
 }
开发者ID:spf13,项目名称:symfony,代码行数:11,代码来源:ContainerTest.php

示例14: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $file = sprintf('%s/%s', $this->getRoot(), $this->file);
     $output->writeln('Caching the container:');
     $output->writeln(sprintf("\tFile:\t\t%s", $file));
     $container = \Maverick\bootstrap($this->getRoot(), true);
     $container->compile();
     $dumper = new PhpDumper($container);
     $dumped = $dumper->dump(['namespace' => $this->namespace, 'class' => $this->class]);
     file_put_contents($file, $dumped);
 }
开发者ID:alecgunnar,项目名称:maverick,代码行数:11,代码来源:CacheContainerBuildStep.php

示例15: getDumpedContainer

 protected function getDumpedContainer()
 {
     static $i = 0;
     $class = 'PaginatorExtensionTestContainer' . $i++;
     $this->container->compile();
     $dumper = new PhpDumper($this->container);
     eval('?>' . $dumper->dump(array('class' => $class)));
     $container = new $class();
     $container->enterScope('request');
     $container->set('kernel', $this->kernel);
     return $container;
 }
开发者ID:nucleartux,项目名称:KnpPaginatorBundle,代码行数:12,代码来源:BaseTestCase.php


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