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


PHP ContainerBuilder::getResources方法代码示例

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


在下文中一共展示了ContainerBuilder::getResources方法的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: loadServiceContainer

 /**
  * @param DnaConfiguration $dna
  * 
  * @return \Nucleus\IService\DependencyInjection\IServiceContainer
  */
 protected function loadServiceContainer($dna)
 {
     $cachePath = $dna->freezeCachePath()->getCachePath();
     $class = 'ServiceContainer' . md5($cachePath);
     $file = $cachePath . '/serviceContainer/' . $class . '.php';
     $containerConfigCache = new ConfigCache($file, $dna->getDebug());
     $isNew = false;
     if (!class_exists($class)) {
         if (!$containerConfigCache->isFresh()) {
             $container = new ContainerBuilder();
             $nucleusCompilerPass = new NucleusCompilerPass($dna);
             $container->addCompilerPass($nucleusCompilerPass);
             $container->compile();
             $dumper = new PhpDumper($container);
             $containerConfigCache->write($dumper->dump(array('class' => $class, 'nucleus' => $nucleusCompilerPass->getConfiguration())), $container->getResources());
             $isNew = true;
         }
         require $file;
     }
     $serviceContainer = new $class();
     /* @var $serviceContainer \Nucleus\DependencyInjection\BaseServiceContainer */
     $serviceContainer->initialize();
     if ($isNew) {
         $serviceContainer->getServiceByName(IEventDispatcherService::NUCLEUS_SERVICE_NAME)->dispatch('ServiceContainer.postDump', $serviceContainer, array('containerBuilder' => $container, 'dnaConfiguration' => $dna));
     }
     return $serviceContainer;
 }
开发者ID:mpoiriert,项目名称:nucleus,代码行数:32,代码来源:Nucleus.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: process

 /**
  * @param ContainerBuilder $container
  */
 public function process(ContainerBuilder $container)
 {
     if ($container->hasDefinition('doctrine_mongodb.odm.listeners.resolve_target_document')) {
         $resourcePath = '.';
         foreach ($container->getResources() as $resource) {
             if (!$resource instanceof FileResource) {
                 continue;
             }
             $resourcePath = (string) $resource;
             if (is_string($resourcePath)) {
                 if (strpos($resourcePath, 'BaseApiMongoModelBundle') && strpos($resourcePath, 'config') && strpos($resourcePath, 'yml') === false && strpos($resourcePath, 'validation') === false) {
                     break;
                 }
             }
         }
         $defaultResolveDocument = Yaml::parse(file_get_contents($resourcePath . '/resolve_document.yml'))['resolve_target_documents'];
         $definition = $container->findDefinition('doctrine_mongodb.odm.listeners.resolve_target_document');
         $definitionCalls = $definition->getMethodCalls();
         foreach ($defaultResolveDocument as $interface => $class) {
             if (!$this->resolverExist($definitionCalls, $interface)) {
                 $definition->addMethodCall('addResolveTargetDocument', array($interface, $class, array()));
             }
         }
     }
 }
开发者ID:open-orchestra,项目名称:open-orchestra-base-api-mongo-model-bundle,代码行数:28,代码来源:EntityResolverCompilerPass.php

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

示例6: testAddResource

 public function testAddResource()
 {
     $containerBuilder = new ContainerBuilder();
     $configBuilder = new PoliciesConfigBuilder($containerBuilder);
     $resource1 = new FileResource(__FILE__);
     $resource2 = new DirectoryResource(__DIR__);
     $configBuilder->addResource($resource1);
     $configBuilder->addResource($resource2);
     self::assertSame([$resource1, $resource2], $containerBuilder->getResources());
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:10,代码来源:PoliciesConfigBuilderTest.php

示例7: 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);
         $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,代码行数:15,代码来源:container_builder.php

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

示例9: getDirBundle

 /**
  * Modifica el atributo $direccionBundle de esta clase con la dirección del Bundle actual en que se instancia el objeto.
  *
  * @param $container
  * @param string $dir Dirección hasta DedendencyInjection del bundle a obtener la dirección.
  */
 private function getDirBundle(ContainerBuilder $container, $dir)
 {
     $resources = $container->getResources();
     foreach ($resources as $resource) {
         if (strpos($resource, $dir) !== false) {
             $this->direccionBundle = substr($dir, 0, strlen($dir) - 20);
             $arrayDirBundleSplited = explode(DIRECTORY_SEPARATOR, $this->direccionBundle);
             $this->nameBundle = $arrayDirBundleSplited[count($arrayDirBundleSplited) - 1];
             break;
         }
     }
 }
开发者ID:bosonsymfony,项目名称:excepciones-bundle,代码行数:18,代码来源:ExcepcionesExtension.php

示例10: testConfigFreshness

 public function testConfigFreshness()
 {
     touch(__FILE__, time() - 3600);
     $cache = new ConfigCache(static::$cacheDir . DIRECTORY_SEPARATOR . 'cache', TRUE);
     $container = new ContainerBuilder();
     $locator = new FileLocator(__DIR__);
     $loader = new YamlArrayLoader($container, $locator);
     $loader->load(__FILE__, NULL, array('parameters' => array('x' => 'y')));
     $container->compile();
     $dumper = new PhpDumper($container);
     $cache->write($dumper->dump(), $container->getResources());
     $this->assertTrue($cache->isFresh());
     touch(__FILE__, time() + 5);
     $this->assertFalse($cache->isFresh());
     $this->assertEquals($container->getParameter('x'), 'y');
 }
开发者ID:frizinak,项目名称:drupony,代码行数:16,代码来源:YamlArrayLoaderTest.php

示例11: nativeSerializers

 /**
  * @test native serializer configuration
  */
 public function nativeSerializers()
 {
     $this->loadExtension(['serializers' => ['default' => ['native' => []]]], false);
     $id = EventBandExtension::getSerializerId('default');
     $this->assertTrue($this->container->hasDefinition($id));
     $this->container->getDefinition($id)->setPublic(true);
     $this->container->compile();
     $serializer = $this->container->get($id);
     $this->assertInstanceOf('EventBand\\Serializer\\NativeEventSerializer', $serializer);
     // Test no serializer configs are loaded
     $resources = $this->container->getResources();
     /** @var FileResource $resource */
     foreach ($resources as $resource) {
         $this->assertNotContains('EventBand/SymfonyBundle/Resources/config/serializer/', $resource->getResource());
     }
 }
开发者ID:coyl,项目名称:EventBandSymfonyBundle,代码行数:19,代码来源:EventBandExtensionTest.php

示例12: build

 /**
  * Build the container.
  *
  * @param string $configDir
  * @param string $configFile
  * @param string $className
  * @param string $namespace
  *
  * @return Container
  */
 public function build($configDir, $configFile, $className = 'CachedContainer', $namespace = 'Cache')
 {
     if ($this->debug) {
         // provides useful info regarding namespace when in debug, ignored in prod for performance
         self::checkNamespace($namespace);
         self::checkClassName($className);
     }
     $fqClassName = '\\' . $namespace . '\\' . $className;
     $cacheFile = $this->cacheDir . '/' . $className . '.php';
     $configCache = new ConfigCache($cacheFile, $this->debug);
     if (!$configCache->isFresh()) {
         $containerBuilder = new ContainerBuilder();
         $loader = new YamlFileLoader($containerBuilder, new FileLocator($configDir));
         $loader->load($configFile);
         $containerBuilder->compile();
         $dumper = new PhpDumper($containerBuilder);
         $configCache->write($dumper->dump(['class' => $className, 'namespace' => $namespace]), $containerBuilder->getResources());
     }
     return new $fqClassName();
 }
开发者ID:remi-san,项目名称:sf-di-tools,代码行数:30,代码来源:YamlCachedContainerBuilder.php

示例13: process

 public function process(ContainerBuilder $container)
 {
     $resources = $directories = array();
     $ref = new \ReflectionProperty('Symfony\\Component\\Config\\Resource\\DirectoryResource', 'pattern');
     $ref->setAccessible(true);
     foreach ($container->getResources() as $resource) {
         if ($resource instanceof DirectoryResource) {
             if (null === ($pattern = $ref->getValue($resource))) {
                 $pattern = '*';
             }
             $directories[$pattern][] = $resource->getResource();
             continue;
         }
         $resources[] = $resource;
     }
     $sortFunc = function ($a, $b) {
         return strlen($a) - strlen($b);
     };
     foreach ($directories as $pattern => $pDirectories) {
         $newResources = array();
         usort($pDirectories, $sortFunc);
         foreach ($pDirectories as $a) {
             foreach ($newResources as $b) {
                 if (0 === strpos($a, $b)) {
                     continue 2;
                 }
             }
             $newResources[] = $a;
         }
         $directories[$pattern] = $newResources;
     }
     $disableGrep = $container->getParameter('jms_di_extra.disable_grep');
     foreach ($directories as $pattern => $pDirectories) {
         $newResource = new FastDirectoriesResource($pDirectories, $pattern, $disableGrep);
         $newResource->update();
         $resources[] = $newResource;
     }
     $ref = new \ReflectionProperty('Symfony\\Component\\DependencyInjection\\ContainerBuilder', 'resources');
     $ref->setAccessible(true);
     $ref->setValue($container, $resources);
 }
开发者ID:everhour,项目名称:JMSDiExtraBundle,代码行数:41,代码来源:ResourceOptimizationPass.php

示例14: create

 /**
  * Returns a new created container instance.
  *
  * @param string $environment
  * @param bool   $debug
  *
  * @return ContainerInterface
  */
 public function create($environment, $debug = false)
 {
     $cachedContainerClassName = ucfirst($environment) . ($debug ? 'Debug' : '') . 'Container';
     $cache = new ConfigCache($this->cacheDir . '/' . $cachedContainerClassName . '.php', $debug);
     if (!$cache->isFresh()) {
         $container = new ContainerBuilder(new ParameterBag(['environment' => $environment, 'debug' => $debug]));
         $container->addObjectResource($this);
         foreach ($this->loaders as $loader) {
             (new ClosureLoader($container))->load($loader);
         }
         $container->compile();
         $dumper = new PhpDumper($container);
         $content = $dumper->dump(['class' => stristr(basename($cache->getPath()), '.', true)]);
         $cache->write($debug ? $content : self::stripComments($content), $container->getResources());
         if ($debug) {
             self::dumpForDebug(preg_replace('/\\.php/', '.xml', $cache->getPath()), $container);
         }
     }
     require_once $cache->getPath();
     return new $cachedContainerClassName();
 }
开发者ID:issei-m,项目名称:symfony-dic-demo,代码行数:29,代码来源:ContainerFactory.php

示例15: init

 /**
  * {@inheritdoc}
  */
 public function init(array $options = array())
 {
     $file = rtrim($options['cacheDir'], '/') . '/AspectServiceContainer.php';
     $containerConfigCache = new ConfigCache($file, !empty($options['debug']));
     if (!$containerConfigCache->isFresh()) {
         $container = new ContainerBuilder();
         $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Resources'));
         $loader->load('components.xml');
         $loader->load('aspect.xml');
         $loader->load('demo_aspects.xml');
         // TODO: Remove this hardcoded example
         $container->addCompilerPass(new ComponentScannerPass($options['appDir'] . '/src'));
         $container->addCompilerPass(new AspectCollectorPass());
         $container->addCompilerPass(new InterfaceBinderPass(), PassConfig::TYPE_AFTER_REMOVING);
         $container->setParameter('kernel.interceptFunctions', !empty($options['interceptFunctions']));
         $container->compile();
         $dumper = new PhpDumper($container);
         $containerConfigCache->write($dumper->dump(array('base_class' => 'Warlock\\WarlockContainer', 'class' => static::$containerClass)), $container->getResources());
     }
     require_once $file;
     parent::init($options);
     $this->container->addResource($file);
 }
开发者ID:ssgonchar,项目名称:warlock,代码行数:26,代码来源:WarlockKernel.php


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