本文整理汇总了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));
}
示例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');
}
示例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;
}
示例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;
}
示例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');
}
示例7: enterScope
public function enterScope($name)
{
return $this->delegate->enterScope($name);
}