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


PHP ContainerBuilder::addResource方法代码示例

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


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

示例1: realpath

 /**
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  * @param \Doctrine\Common\Annotations\AnnotationReader $annotationReader
  * @param \FSi\Bundle\AdminBundle\Finder\AdminClassFinder $adminClassFinder
  */
 function it_registers_annotated_admin_classes_as_services($container, $annotationReader, $adminClassFinder)
 {
     $container->getParameter('kernel.bundles')->willReturn(array('FSi\\Bundle\\AdminBundle\\spec\\fixtures\\MyBundle', 'FSi\\Bundle\\AdminBundle\\FSiAdminBundle', 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'));
     $baseDir = __DIR__ . '/../../../../../..';
     $adminClassFinder->findClasses(array(realpath($baseDir . '/spec/fixtures/Admin'), realpath($baseDir . '/Admin')))->willReturn(array('FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\CRUDElement'));
     $annotationReader->getClassAnnotation(Argument::allOf(Argument::type('ReflectionClass'), Argument::which('getName', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\CRUDElement')), 'FSi\\Bundle\\AdminBundle\\Annotation\\Element')->willReturn(null);
     $annotationReader->getClassAnnotation(Argument::allOf(Argument::type('ReflectionClass'), Argument::which('getName', 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement')), 'FSi\\Bundle\\AdminBundle\\Annotation\\Element')->willReturn(new Element(array()));
     $container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'), Argument::which('getResource', realpath($baseDir . '/spec/fixtures/Admin')), Argument::which('getPattern', '/\\.php$/')))->shouldBeCalled();
     $container->addResource(Argument::allOf(Argument::type('Symfony\\Component\\Config\\Resource\\DirectoryResource'), Argument::which('getResource', realpath($baseDir . '/Admin')), Argument::which('getPattern', '/\\.php$/')))->shouldBeCalled();
     $container->addDefinitions(Argument::that(function ($definitions) {
         if (count($definitions) !== 1) {
             return false;
         }
         /** @var \Symfony\Component\DependencyInjection\Definition $definition */
         $definition = $definitions[0];
         if ($definition->getClass() !== 'FSi\\Bundle\\AdminBundle\\spec\\fixtures\\Admin\\SimpleAdminElement') {
             return false;
         }
         if (!$definition->hasTag('admin.element')) {
             return false;
         }
         return true;
     }))->shouldBeCalled();
     $this->process($container);
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:30,代码来源:AdminAnnotatedElementPassSpec.php

示例2: prepend

 /**
  * Allow an extension to prepend the extension configurations.
  *
  * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
  */
 public function prepend(ContainerBuilder $container)
 {
     $configFile = __DIR__ . '/../Resources/config/templates.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($configFile));
 }
开发者ID:eab-dev,项目名称:UniqueDatatypesBundle,代码行数:12,代码来源:EabUniqueDatatypesExtension.php

示例3: load

 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuredMenus = array();
     if (is_file($file = $container->getParameter('kernel.root_dir') . '/config/navigation.yml')) {
         $configuredMenus = $this->parseFile($file);
         $container->addResource(new FileResource($file));
     }
     foreach ($container->getParameter('kernel.bundles') as $bundle) {
         $reflection = new \ReflectionClass($bundle);
         if (is_file($file = dirname($reflection->getFilename()) . '/Resources/config/navigation.yml')) {
             $configuredMenus = array_replace_recursive($configuredMenus, $this->parseFile($file));
             $container->addResource(new FileResource($file));
         }
     }
     $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.yml');
     // validate menu configurations
     foreach ($configuredMenus as $rootName => $menuConfiguration) {
         $configuration = new NavigationConfiguration();
         $configuration->setMenuRootName($rootName);
         $menuConfiguration[$rootName] = $this->processConfiguration($configuration, array($rootName => $menuConfiguration));
     }
     // Set configuration to be used in a custom service
     $container->setParameter('jb_config.menu.configuration', $configuredMenus);
     // Last argument of this service is always the menu configuration
     $container->getDefinition('jb_config.menu.provider')->addArgument($configuredMenus);
 }
开发者ID:munkie,项目名称:ConfigKnpMenuBundle,代码行数:30,代码来源:JbConfigKnpMenuExtension.php

示例4: prepend

 /**
  * Loads DemoBundle configuration.
  *
  * @param ContainerBuilder $container
  */
 public function prepend(ContainerBuilder $container)
 {
     // Add legacy bundle settings only if it's present.
     if ($container->hasExtension('ez_publish_legacy')) {
         $legacyConfigFile = __DIR__ . '/../Resources/config/legacy_settings.yml';
         $config = Yaml::parse(file_get_contents($legacyConfigFile));
         $container->prependExtensionConfig('ez_publish_legacy', $config);
         $container->addResource(new FileResource($legacyConfigFile));
     }
     $configFile = __DIR__ . '/../Resources/config/ezdemo.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($configFile));
     $configFile = __DIR__ . '/../Resources/config/image_variations.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($configFile));
     $ezpageConfigFile = __DIR__ . '/../Resources/config/ezpage.yml';
     $ezpageConfig = Yaml::parse(file_get_contents($ezpageConfigFile));
     $container->prependExtensionConfig('ezpublish', $ezpageConfig);
     $container->addResource(new FileResource($ezpageConfigFile));
     $ezCommentsConfigFile = __DIR__ . '/../Resources/config/ezcomments.yml';
     $ezCommentsConfig = Yaml::parse(file_get_contents($ezCommentsConfigFile));
     $container->prependExtensionConfig('ez_comments', $ezCommentsConfig);
     $container->addResource(new FileResource($ezCommentsConfigFile));
 }
开发者ID:ezsystems,项目名称:demobundle,代码行数:31,代码来源:eZDemoExtension.php

示例5: testParameters

 public function testParameters()
 {
     $path = Path::join([DATAFIXTURES_DIR, 'config', 'test-parameters.json']);
     $this->locator->locate('test-parameters.json')->willReturn($path);
     $this->container->addResource(Argument::that(function (FileResource $resource) use($path) {
         return $resource->getResource() === $path;
     }))->shouldBeCalled();
     $this->container->loadFromExtension('test-parameters', ['name' => 'test'])->shouldBeCalled();
     $this->container->setParameter('test', 'value')->shouldBeCalled();
     $this->loader->load('test-parameters.json');
 }
开发者ID:nanbando,项目名称:core,代码行数:11,代码来源:JsonLoaderTest.php

示例6: testProcess

 public function testProcess()
 {
     $container = new ContainerBuilder();
     $container->addResource(new DirectoryResource(__DIR__ . '/Fixtures/a'));
     $container->addResource(new DirectoryResource(__DIR__ . '/Fixtures/a/b'));
     $container->addResource(new DirectoryResource(__DIR__ . '/Fixtures/c'));
     $this->process($container);
     $resources = $container->getResources();
     $this->assertEquals(1, count($resources));
     $this->assertInstanceOf('JMS\\DiExtraBundle\\Config\\FastDirectoriesResource', $resources[0]);
     $this->assertEquals(array(__DIR__ . '/Fixtures/a', __DIR__ . '/Fixtures/c'), $resources[0]->getResource());
     $this->assertAttributeEquals('*', 'filePattern', $resources[0]);
 }
开发者ID:joan16v,项目名称:symfony2_test,代码行数:13,代码来源:ResourceOptimizationPassTest.php

示例7: process

 public function process(ContainerBuilder $container)
 {
     if ($container->has('form.extension')) {
         $container->getDefinition('twig.extension.form')->addTag('twig.extension');
         $reflClass = new \ReflectionClass('Symfony\\Bridge\\Twig\\Extension\\FormExtension');
         $container->getDefinition('twig.loader.filesystem')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())) . '/Resources/views/Form'));
     }
     if ($container->has('translator')) {
         $container->getDefinition('twig.extension.trans')->addTag('twig.extension');
     }
     if ($container->has('router')) {
         $container->getDefinition('twig.extension.routing')->addTag('twig.extension');
     }
     if ($container->has('fragment.handler')) {
         $container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension');
         // inject Twig in the hinclude service if Twig is the only registered templating engine
         if (!$container->hasParameter('templating.engines') || array('twig') == $container->getParameter('templating.engines')) {
             $container->getDefinition('fragment.renderer.hinclude')->addTag('kernel.fragment_renderer', array('alias' => 'hinclude'))->replaceArgument(0, new Reference('twig'));
         }
     }
     if ($container->has('request_stack')) {
         $container->getDefinition('twig.extension.httpfoundation')->addTag('twig.extension');
     }
     if ($container->getParameter('kernel.debug')) {
         $container->getDefinition('twig.extension.profiler')->addTag('twig.extension');
         $container->getDefinition('twig.extension.debug')->addTag('twig.extension');
     }
     if (!$container->has('templating')) {
         $loader = $container->getDefinition('twig.loader.native_filesystem');
         $loader->replaceArgument(1, $this->getComposerRootDir($container->getParameter('kernel.root_dir')));
         $loader->addTag('twig.loader');
         $loader->setMethodCalls($container->getDefinition('twig.loader.filesystem')->getMethodCalls());
         $container->setDefinition('twig.loader.filesystem', $loader);
     }
     if ($container->has('assets.packages')) {
         $container->getDefinition('twig.extension.assets')->addTag('twig.extension');
     }
     $container->addResource(new ClassExistenceResource(YamlParser::class));
     if (class_exists(YamlParser::class)) {
         $container->getDefinition('twig.extension.yaml')->addTag('twig.extension');
     }
     $container->addResource(new ClassExistenceResource(Stopwatch::class));
     if (class_exists(Stopwatch::class)) {
         $container->getDefinition('twig.extension.debug.stopwatch')->addTag('twig.extension');
     }
     $container->addResource(new ClassExistenceResource(ExpressionLanguage::class));
     if (class_exists(ExpressionLanguage::class)) {
         $container->getDefinition('twig.extension.expression')->addTag('twig.extension');
     }
 }
开发者ID:yceruto,项目名称:symfony,代码行数:50,代码来源:ExtensionPass.php

示例8: prepend

 /**
  * Loads DemoBundle configuration.
  *
  * @param ContainerBuilder $container
  */
 public function prepend(ContainerBuilder $container)
 {
     $configFile = __DIR__ . '/../Resources/config/ezdemo.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($configFile));
     $ezpageConfigFile = __DIR__ . '/../Resources/config/ezpage.yml';
     $ezpageConfig = Yaml::parse(file_get_contents($ezpageConfigFile));
     $container->prependExtensionConfig('ezpublish', $ezpageConfig);
     $container->addResource(new FileResource($ezpageConfigFile));
     $ezCommentsConfigFile = __DIR__ . '/../Resources/config/ezcomments.yml';
     $ezCommentsConfig = Yaml::parse(file_get_contents($ezCommentsConfigFile));
     $container->prependExtensionConfig('ez_comments', $ezCommentsConfig);
     $container->addResource(new FileResource($ezCommentsConfigFile));
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:20,代码来源:eZDemoExtension.php

示例9: prepend

 /**
  * Loads SimpleDesignBundle configuration.
  *
  * @param ContainerBuilder $container
  */
 public function prepend(ContainerBuilder $container)
 {
     $legacyConfigFile = __DIR__ . '/../Resources/config/legacy_settings.yml';
     $config = Yaml::parse(file_get_contents($legacyConfigFile));
     $container->prependExtensionConfig('ez_publish_legacy', $config);
     $container->addResource(new FileResource($legacyConfigFile));
     $designConfigFile = __DIR__ . '/../Resources/config/simpledesign.yml';
     $config = Yaml::parse(file_get_contents($designConfigFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($designConfigFile));
     $configFile = __DIR__ . '/../Resources/config/image_variations.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('ezpublish', $config);
     $container->addResource(new FileResource($configFile));
 }
开发者ID:bananamanu,项目名称:SimpleDesignBundle,代码行数:20,代码来源:BananamanuSimpleDesignExtension.php

示例10:

 function it_loads_configuration_files(ContainerBuilder $container)
 {
     $container->addResource(Argument::any())->shouldBeCalled();
     $container->setParameter(Argument::cetera())->shouldBeCalled();
     $container->setDefinition(Argument::cetera())->shouldBeCalled();
     $this->load([], $container);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:7,代码来源:PimTranslationExtensionSpec.php

示例11: prepend

 /**
  * Allows an extension to prepend the extension configurations.
  *
  * @param ContainerBuilder $container ContainerBuilder object
  */
 public function prepend(ContainerBuilder $container)
 {
     $configFile = dirname(__DIR__) . '/Resources/config/aimeos_shop.yml';
     $config = Yaml::parse(file_get_contents($configFile));
     $container->prependExtensionConfig('aimeos_shop', $config);
     $container->addResource(new FileResource($configFile));
 }
开发者ID:gvandencruche,项目名称:aimeos-symfony,代码行数:12,代码来源:AimeosShopExtension.php

示例12: prependRest

 public function prependRest(ContainerBuilder $container)
 {
     $restFile = __DIR__ . '/../Resources/config/default_settings.yml';
     $config = Yaml::parse(file_get_contents($restFile));
     $container->prependExtensionConfig('ez_publish_rest', $config);
     $container->addResource(new FileResource($restFile));
 }
开发者ID:dspe,项目名称:pvrezcommentbundle,代码行数:7,代码来源:PvrEzCommentExtension.php

示例13: getConfiguration

 public function getConfiguration(array $config, ContainerBuilder $container)
 {
     $configuration = new Configuration($this->getAlias());
     $r = new \ReflectionObject($configuration);
     $container->addResource(new FileResource($r->getFileName()));
     return $configuration;
 }
开发者ID:sstok,项目名称:rollerworks-datagrid-bundle,代码行数:7,代码来源:DatagridExtension.php

示例14: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasParameter('fos_user.storage')) {
         return;
     }
     $storage = $container->getParameter('fos_user.storage');
     if ('custom' === $storage) {
         return;
     }
     $validationFile = __DIR__ . '/../../Resources/config/validation/' . $storage . '.xml';
     if ($container->hasDefinition('validator.builder')) {
         // Symfony 2.5+
         $container->getDefinition('validator.builder')->addMethodCall('addXmlMapping', array($validationFile));
         return;
     }
     // Old method of loading validation
     if (!$container->hasParameter('validator.mapping.loader.xml_files_loader.mapping_files')) {
         return;
     }
     $files = $container->getParameter('validator.mapping.loader.xml_files_loader.mapping_files');
     if (is_file($validationFile)) {
         $files[] = realpath($validationFile);
         $container->addResource(new FileResource($validationFile));
     }
     $container->setParameter('validator.mapping.loader.xml_files_loader.mapping_files', $files);
 }
开发者ID:jjspider277,项目名称:weddings,代码行数:29,代码来源:ValidationPass.php

示例15: load

 /** {@inheritdoc} */
 public function load(array $config, ContainerBuilder $container)
 {
     // Load configuration
     (new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')))->load('webpack.yml');
     // Retrieve all configuration entities
     $bundles = $container->getParameter('kernel.bundles');
     $builder_definition = $container->getDefinition('hostnet_webpack.bridge.config_generator');
     $config_extension_ids = array_keys($container->findTaggedServiceIds('hostnet_webpack.config_extension'));
     $config_definitions = [];
     $config_class_names = [];
     foreach ($config_extension_ids as $id) {
         $config_definitions[$id] = $container->getDefinition($id);
         $config_class_names[$id] = $container->getDefinition($id)->getClass();
     }
     $configuration = new Configuration(array_keys($bundles), $config_class_names);
     $config = $this->processConfiguration($configuration, $config);
     $container->addResource(new FileResource((new \ReflectionClass(Configuration::class))->getFileName()));
     // Select the correct node binary for the platform we're currently running on.
     $config['node']['binary'] = $config['node']['binary'][$this->getPlatformKey()];
     $config['node']['node_modules_path'] = !empty($config['node']['node_modules_path']) ? $config['node']['node_modules_path'] : getenv('NODE_PATH');
     // Parse application config into the config generator
     foreach ($config_definitions as $id => $definition) {
         /* @var $definition Definition */
         $builder_definition->addMethodCall('addExtension', [new Reference($id)]);
         $definition->addArgument($config);
     }
     // Pass the configuration to a container parameter for the CompilerPass and profiler to read.
     $container->setParameter('hostnet_webpack_config', $config);
 }
开发者ID:studionone,项目名称:webpack-bundle,代码行数:30,代码来源:WebpackExtension.php


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