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


PHP ContainerBuilder::enterScope方法代码示例

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


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

示例1: testOnKernelFinishRequest

 /**
  * Tests the onKernelFinishRequest method.
  */
 public function testOnKernelFinishRequest()
 {
     $this->container->addScope(new Scope(ContaoCoreBundle::SCOPE_BACKEND, 'request'));
     $this->container->enterScope(ContaoCoreBundle::SCOPE_BACKEND);
     /** @var HttpKernelInterface $kernel */
     $kernel = $this->getMockForAbstractClass('Symfony\\Component\\HttpKernel\\Kernel', ['test', false]);
     $request = new Request();
     $request->attributes->set('_scope', ContaoCoreBundle::SCOPE_BACKEND);
     $listener = new ContainerScopeListener($this->container);
     $listener->onKernelFinishRequest(new FinishRequestEvent($kernel, $request, new Response()));
     $this->assertTrue($this->container->hasScope(ContaoCoreBundle::SCOPE_BACKEND));
     $this->assertFalse($this->container->isScopeActive(ContaoCoreBundle::SCOPE_BACKEND));
 }
开发者ID:contao,项目名称:core-bundle,代码行数:16,代码来源:ContainerScopeListenerTest.php

示例2: testPlacesAutocompleteFormType

 public function testPlacesAutocompleteFormType()
 {
     $this->loadConfiguration($this->container, 'empty');
     $this->container->compile();
     $this->container->enterScope('request');
     $this->assertInstanceOf('Ivory\\GoogleMapBundle\\Form\\Type\\PlacesAutocompleteType', $this->container->get('ivory_google_map.places_autocomplete.form.type'));
     $this->container->leaveScope('request');
 }
开发者ID:acrobat,项目名称:IvoryGoogleMapBundle,代码行数:8,代码来源:AbstractIvoryGoogleMapExtensionTest.php

示例3: testBaseSetup

 /**
  * @dataProvider getDebugModes
  */
 public function testBaseSetup($debug)
 {
     $this->container->setParameter('kernel.debug', $debug);
     $this->container->enterScope('request');
     $this->container->set('request', Request::create('/'));
     $this->container->set('kernel', $this->kernel);
     $extension = new PlatinumPixsGoogleClosureLibraryExtension();
     $extension->load(array('platinum_pixs_google_closure_library' => array('outputMode' => 'compiled', 'compilerFlags' => array('--compilation_level=ADVANCED_OPTIMIZATIONS', "--define='somevariableinside=somevalue'"), 'externs' => array("src/PlatinumPixs/TestBundle/Resources/javascript/loggly-externs.js"), 'root' => array("src/PlatinumPixs/TestBundle/Resources/javascript"))), $this->container);
     $errors = array();
     foreach ($this->container->getServiceIds() as $id) {
         try {
             $this->container->get($id);
         } catch (\Exception $e) {
             print $e->getMessage();
             $errors[$id] = $e->getMessage();
         }
     }
     self::assertEquals(array(), $errors, '');
 }
开发者ID:platinumpixs,项目名称:symfony2-google-closure-library,代码行数:22,代码来源:PlatinumPixsGoogleClosureLibraryExtensionTest.php

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

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

示例6: testSynchronizedServiceWithScopes

 public function testSynchronizedServiceWithScopes()
 {
     $container = new ContainerBuilder();
     $container->addScope(new Scope('foo'));
     $container->register('baz', 'BazClass')->setSynthetic(true)->setSynchronized(true)->setScope('foo');
     $container->register('bar', 'BarClass')->addMethodCall('setBaz', array(new Reference('baz', ContainerInterface::NULL_ON_INVALID_REFERENCE, false)));
     $container->compile();
     $container->enterScope('foo');
     $container->set('baz', $outerBaz = new \BazClass(), 'foo');
     $this->assertSame($outerBaz, $container->get('bar')->getBaz());
     $container->enterScope('foo');
     $container->set('baz', $innerBaz = new \BazClass(), 'foo');
     $this->assertSame($innerBaz, $container->get('bar')->getBaz());
     $container->leaveScope('foo');
     $this->assertNotSame($innerBaz, $container->get('bar')->getBaz());
     $this->assertSame($outerBaz, $container->get('bar')->getBaz());
     $container->leaveScope('foo');
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:18,代码来源:ContainerBuilderTest.php

示例7: enterScope

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


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