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


PHP ContainerBuilder::addScope方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     if (!class_exists('Assetic\\AssetManager')) {
         $this->markTestSkipped('Assetic is not available.');
     }
     if (!class_exists('Twig_Environment')) {
         $this->markTestSkipped('Twig is not available.');
     }
     $this->kernel = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\KernelInterface')->getMock();
     $this->container = new ContainerBuilder();
     // Symfony 2.3 BC
     if (!method_exists('Symfony\\Component\\DependencyInjection\\Definition', 'setShared')) {
         $this->container->addScope(new Scope('request'));
         $this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     }
     // Symfony <2.7 BC
     if (class_exists('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\AssetsHelper')) {
         $this->container->register('assets.packages', $this->getMockClass('Symfony\\Component\\Asset\\Packages'));
         $this->container->register('templating.helper.assets', $this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\AssetsHelper'))->addArgument(new Reference('assets.packages'));
     } elseif (class_exists('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')) {
         $this->container->register('templating.helper.assets', $this->getMockClass('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper'))->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Templating\\Asset\\PackageInterface')));
     }
     $this->container->register('templating.helper.router', $this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\RouterHelper'))->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')));
     $this->container->register('twig', 'Twig_Environment')->addArgument(new Definition($this->getMockClass('Twig_LoaderInterface')));
     $this->container->setParameter('kernel.bundles', array());
     $this->container->setParameter('kernel.cache_dir', __DIR__);
     $this->container->setParameter('kernel.debug', false);
     $this->container->setParameter('kernel.root_dir', __DIR__);
     $this->container->setParameter('kernel.charset', 'UTF-8');
     $this->container->set('kernel', $this->kernel);
     $this->container->addCompilerPass(new StaticAsseticHelperPass());
 }
开发者ID:symfony,项目名称:assetic-bundle,代码行数:32,代码来源:AsseticExtensionTest.php

示例2: testProcessDetectsCrossScopeHierarchyReference

 /**
  * @expectedException \RuntimeException
  * @group legacy
  */
 public function testProcessDetectsCrossScopeHierarchyReference()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('a'));
     $container->addScope(new Scope('b'));
     $container->register('a')->setScope('a')->addArgument(new Reference('b'));
     $container->register('b')->setScope('b');
     $this->process($container);
 }
开发者ID:Kyra2778,项目名称:AMR,代码行数:13,代码来源:CheckReferenceValidityPassTest.php

示例3: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->requestMock = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $this->container = new ContainerBuilder();
     $this->container->addScope(new Scope('request'));
     $this->container->setParameter('templating.engines', array('php', 'twig'));
     $this->container->set('request', $this->requestMock);
     $this->container->registerExtension(new IvoryGoogleMapExtension());
     $this->container->registerExtension($httpAdapterExtension = new WidopHttpAdapterExtension());
     $this->container->loadFromExtension($httpAdapterExtension->getAlias());
 }
开发者ID:acrobat,项目名称:IvoryGoogleMapBundle,代码行数:14,代码来源:AbstractIvoryGoogleMapExtensionTest.php

示例4: setUp

 protected function setUp()
 {
     $this->kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
     $this->container = new ContainerBuilder();
     $this->container->addScope(new Scope('request'));
     $this->container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $this->container->register('templating.helper.assets', $this->getMockClass('Symfony\\Component\\Templating\\Helper\\AssetsHelper'));
     $this->container->register('templating.helper.router', $this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\RouterHelper'))->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')));
     $this->container->register('twig', 'Twig_Environment');
     $this->container->setParameter('kernel.bundles', array());
     $this->container->setParameter('kernel.cache_dir', __DIR__);
     $this->container->setParameter('webroot', __DIR__);
     $this->container->setParameter('kernel.debug', false);
     $this->container->setParameter('kernel.root_dir', __DIR__);
     $this->container->setParameter('kernel.charset', 'UTF-8');
     $this->container->set('kernel', $this->kernel);
 }
开发者ID:platinumpixs,项目名称:symfony2-google-closure-library,代码行数:17,代码来源:PlatinumPixsGoogleClosureLibraryExtensionTest.php

示例5: testWithoutRequestScope

 /**
  * Tests the onKernelController method without a request scope.
  */
 public function testWithoutRequestScope()
 {
     $this->container->addScope(new Scope(ContaoCoreBundle::SCOPE_BACKEND, 'request'));
     /** @var HttpKernelInterface $kernel */
     $kernel = $this->getMockForAbstractClass('Symfony\\Component\\HttpKernel\\Kernel', ['test', false]);
     $listener = new ContainerScopeListener($this->container);
     $listener->onKernelRequest(new GetResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST));
     $this->assertTrue($this->container->hasScope(ContaoCoreBundle::SCOPE_BACKEND));
     $this->assertFalse($this->container->isScopeActive(ContaoCoreBundle::SCOPE_BACKEND));
 }
开发者ID:contao,项目名称:core-bundle,代码行数:13,代码来源:ContainerScopeListenerTest.php

示例6: testBoot

 /**
  * Tests the boot() method.
  */
 public function testBoot()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('request'));
     $bundle = new ContaoCoreBundle();
     $bundle->setContainer($container);
     $bundle->boot();
     $this->assertTrue($container->hasScope(ContaoCoreBundle::SCOPE_BACKEND));
     $this->assertTrue($container->hasScope(ContaoCoreBundle::SCOPE_FRONTEND));
 }
开发者ID:jamesdevine,项目名称:core-bundle,代码行数:13,代码来源:ContaoCoreBundleTest.php

示例7: testProcessInlinesOnlyIfSameScope

 public function testProcessInlinesOnlyIfSameScope()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('foo'));
     $a = $container->register('a')->setPublic(false)->setScope('foo');
     $b = $container->register('b')->addArgument(new Reference('a'));
     $this->process($container);
     $arguments = $b->getArguments();
     $this->assertEquals(new Reference('a'), $arguments[0]);
     $this->assertTrue($container->hasDefinition('a'));
 }
开发者ID:laubosslink,项目名称:lab,代码行数:11,代码来源:InlineServiceDefinitionsPassTest.php

示例8: createContainerMock

 protected function createContainerMock($render)
 {
     $templatingMock = $this->getMockBuilder('Symfony\\Bundle\\TwigBundle\\TwigEngine')->disableOriginalConstructor()->getMock();
     $templatingMock->expects($this->exactly($render))->method('render');
     $container = new ContainerBuilder();
     $container->set('templating', $templatingMock);
     $container->addScope(new Scope('request'));
     $container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $container->enterScope('request');
     return $container;
 }
开发者ID:firano,项目名称:form-bundle,代码行数:11,代码来源:FormExtensionTest.php

示例9: createContainerMock

 protected function createContainerMock()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('request'));
     $container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $container->enterScope('request');
     $container->set('templating', $this->createTemplatingMock());
     $container->set('router', $this->createRouterMock());
     $container->setParameter('thrace_media.jwplayer.options', array('key' => '123', 'html5player' => 'path_to_file', 'flashplayer' => 'path_to_file'));
     return $container;
 }
开发者ID:thrace-project,项目名称:media-bundle,代码行数:11,代码来源:MediaExtensionTest.php

示例10: getContainer

 private function getContainer()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('request'));
     $container->set('request', $this->request);
     $container->set('templating', $this->templating);
     $container->setParameter('kernel.bundles', array());
     $container->setParameter('kernel.cache_dir', __DIR__);
     $container->setParameter('kernel.root_dir', __DIR__);
     $container->set('kernel', $this->kernel);
     return $container;
 }
开发者ID:laubosslink,项目名称:lab,代码行数:12,代码来源:ExceptionControllerTest.php

示例11: getContainerBuilder

 protected function getContainerBuilder()
 {
     // \sys_get_temp_dir()
     $container = new ContainerBuilder();
     $container->addScope(new Scope('request'));
     $container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $container->setParameter('kernel.debug', false);
     $container->setParameter('kernel.root_dir', __DIR__ . '/temp');
     $container->setParameter('kernel.cache_dir', __DIR__ . '/temp');
     $container->setParameter('kernel.bundles', array());
     return $container;
 }
开发者ID:nucleartux,项目名称:KnpPaginatorBundle,代码行数:12,代码来源:BaseTestCase.php

示例12: getContainer

 private function getContainer()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('request'));
     $container->register('request', 'Symfony\\Component\\HttpFoundation\\Request')->setScope('request');
     $container->register('templating.helper.assets', $this->getMockClass('Symfony\\Component\\Templating\\Helper\\AssetsHelper'));
     $container->register('templating.helper.router', $this->getMockClass('Symfony\\Bundle\\FrameworkBundle\\Templating\\Helper\\RouterHelper'))->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Routing\\RouterInterface')));
     $container->register('twig', 'Twig_Environment');
     $container->register('templating.engine.twig', $this->getMockClass('Symfony\\Bundle\\TwigBundle\\TwigEngine'))->addArgument($this->getMock('Twig_Environment'))->addArgument($this->getMock('Symfony\\Component\\Templating\\TemplateNameParserInterface'))->addArgument(new Definition($this->getMockClass('Symfony\\Component\\Config\\FileLocatorInterface')))->addArgument($this->getMock('Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables', array(), array($this->getMock('Symfony\\Component\\DependencyInjection\\Container'))));
     $container->setAlias('templating', 'templating.engine.twig');
     $container->setParameter('kernel.bundles', array());
     $container->setParameter('kernel.cache_dir', __DIR__);
     $container->setParameter('kernel.root_dir', __DIR__);
     $container->set('kernel', $this->kernel);
     return $container;
 }
开发者ID:usefulthink,项目名称:symfony,代码行数:16,代码来源:ExceptionControllerTest.php

示例13: ContainerBuilder

<?php

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Scope;
$container = new ContainerBuilder();
$container->addScope(new Scope('request'));
$container->register('foo', 'FooClass')->setScope('request');
$container->compile();
return $container;
开发者ID:Dren-x,项目名称:mobit,代码行数:9,代码来源:container18.php

示例14: addScope

 public function addScope(ScopeInterface $scope)
 {
     return $this->delegate->addScope($scope);
 }
开发者ID:planetenkiller,项目名称:core,代码行数:4,代码来源:SandboxContainerBuilder.php

示例15: cloneContainer

 private function cloneContainer()
 {
     $parameterBag = new ParameterBag($this->container->getParameterBag()->all());
     $container = new ContainerBuilder($parameterBag);
     $container->setDefinitions($this->container->getDefinitions());
     $container->setAliases($this->container->getAliases());
     $container->setResources($this->container->getResources());
     foreach ($this->container->getScopes() as $scope => $parentScope) {
         $container->addScope(new Scope($scope, $parentScope));
     }
     foreach ($this->container->getExtensions() as $extension) {
         $container->registerExtension($extension);
     }
     return $container;
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:15,代码来源:GraphvizDumper.php


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