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


PHP RequestStack::push方法代码示例

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


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

示例1: testGetCurrentRouteObject

 /**
  * @covers ::__construct
  * @covers ::getRouteObject
  * @covers ::getCurrentRouteMatch
  * @covers ::getRouteMatch
  */
 public function testGetCurrentRouteObject()
 {
     $request_stack = new RequestStack();
     $request = new Request();
     $request_stack->push($request);
     $current_route_match = new CurrentRouteMatch($request_stack);
     // Before routing.
     $this->assertNull($current_route_match->getRouteObject());
     // After routing.
     $route = new Route('/test-route/{foo}');
     $request->attributes->set(RouteObjectInterface::ROUTE_NAME, 'test_route');
     $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $route);
     $request->attributes->set('foo', '1');
     $this->assertSame('1', $current_route_match->getParameter('foo'));
     // Immutable for the same request once a route has been matched.
     $request->attributes->set('foo', '2');
     $this->assertSame('1', $current_route_match->getParameter('foo'));
     // Subrequest.
     $subrequest = new Request();
     $subrequest->attributes->set(RouteObjectInterface::ROUTE_NAME, 'test_subrequest_route');
     $subrequest->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test-subrequest-route/{foo}'));
     $subrequest->attributes->set('foo', '2');
     $request_stack->push($subrequest);
     $this->assertSame('2', $current_route_match->getParameter('foo'));
     // Restored original request.
     $request_stack->pop();
     $this->assertSame('1', $current_route_match->getParameter('foo'));
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:34,代码来源:CurrentRouteMatchTest.php

示例2: setup

 protected function setup()
 {
     $this->requestStack = new RequestStack();
     $this->requestStack->push(new Request());
     self::bootKernel();
     $this->formFactory = static::$kernel->getContainer()->get('form.factory');
 }
开发者ID:tomazahlin,项目名称:symfony-core-bundle,代码行数:7,代码来源:FormHandlerTest.php

示例3: setUp

 public function setUp()
 {
     $this->requestStack = new RequestStack();
     $request = new Request();
     $this->requestStack->push($request);
     $this->session = new Session(new MockArraySessionStorage());
     $request->setSession($this->session);
     $this->dispatcher = new EventDispatcher();
     $translator = new Translator($this->getMock('\\Symfony\\Component\\DependencyInjection\\ContainerInterface'));
     $token = new TokenProvider($this->requestStack, $translator, 'test');
     $this->dispatcher->addSubscriber(new \Thelia\Action\Cart($this->requestStack, $token));
     $this->session->setSessionCart(null);
     $request->setSession($this->session);
     /** @var \Thelia\Action\Cart  cartAction */
     $this->cartAction = new \Thelia\Action\Cart($this->requestStack, new TokenProvider($this->requestStack, $translator, 'baba au rhum'));
     $this->dispatcherNull = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', array(), array(), '', true, true, true, false);
     $this->dispatcher->expects($this->any())->method('dispatch')->will($this->returnCallback(function ($type, $event) {
         if ($type == TheliaEvents::CART_RESTORE_CURRENT) {
             $this->cartAction->restoreCurrentCart($event, null, $this->dispatcher);
         } elseif ($type == TheliaEvents::CART_CREATE_NEW) {
             $this->cartAction->createEmptyCart($event, null, $this->dispatcher);
         }
     }));
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:25,代码来源:SessionTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->sessionStorage = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface');
     $this->session = $this->getMock('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
     $this->request = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Request')->setMethods(array('hasPreviousSession'))->getMock();
     $this->requestStack = new RequestStack();
     $this->requestStack->push($this->request);
 }
开发者ID:emodric,项目名称:LegacyBridge,代码行数:9,代码来源:SessionTest.php

示例5: setUp

  public function setUp() {
    $request = new Request();

    $this->requestStack = new RequestStack();
    $this->requestStack->push($request);

    $this->session = $this->getMock('\Symfony\Component\HttpFoundation\Session\SessionInterface');
    $request->setSession($this->session);

    $this->cacheContext = new SessionCacheContext($this->requestStack);
  }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:11,代码来源:SessionCacheContextTest.php

示例6: innerHandle

 protected function innerHandle(Request $request, $type)
 {
     $this->requests->push($request);
     if ($this->eventDispatcher !== null) {
         $event = new GetResponseEvent($this, $request, $type);
         $this->eventDispatcher->dispatch(KernelEvents::REQUEST, $event);
         $response = $event->getResponse() ?: $this->router->dispatch($request);
     } else {
         $response = $this->router->dispatch($request);
     }
     return $this->filterResponse($response, $request, $type);
 }
开发者ID:autarky,项目名称:framework,代码行数:12,代码来源:Kernel.php

示例7: testGetParentRequest

 public function testGetParentRequest()
 {
     $requestStack = new RequestStack();
     $this->assertNull($requestStack->getParentRequest());
     $masterRequest = Request::create('/foo');
     $requestStack->push($masterRequest);
     $this->assertNull($requestStack->getParentRequest());
     $firstSubRequest = Request::create('/bar');
     $requestStack->push($firstSubRequest);
     $this->assertSame($masterRequest, $requestStack->getParentRequest());
     $secondSubRequest = Request::create('/baz');
     $requestStack->push($secondSubRequest);
     $this->assertSame($firstSubRequest, $requestStack->getParentRequest());
 }
开发者ID:khangaikh,项目名称:golocal,代码行数:14,代码来源:RequestStackTest.php

示例8: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->keyValue = $this->getMock('Drupal\\Core\\KeyValueStore\\KeyValueStoreExpirableInterface');
     $this->lock = $this->getMock('Drupal\\Core\\Lock\\LockBackendInterface');
     $this->requestStack = new RequestStack();
     $request = Request::createFromGlobals();
     $this->requestStack->push($request);
     $this->tempStore = new SharedTempStore($this->keyValue, $this->lock, $this->owner, $this->requestStack, 604800);
     $this->ownObject = (object) array('data' => 'test_data', 'owner' => $this->owner, 'updated' => (int) $request->server->get('REQUEST_TIME'));
     // Clone the object but change the owner.
     $this->otherObject = clone $this->ownObject;
     $this->otherObject->owner = 2;
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:17,代码来源:SharedTempStoreTest.php

示例9: testConfigureContextOverride

 public function testConfigureContextOverride()
 {
     $request = new Request();
     $request->query->set('_wid', 'test_widget_id');
     $request->query->set('_widgetContainer', 'dialog');
     $this->requestStack->push($request);
     $context = new LayoutContext();
     $context['widget_container'] = 'updated_widget';
     $context->data()->set('widget_id', 'updated_id', 'updated_widget_id');
     $this->contextConfigurator->configureContext($context);
     $context->resolve();
     $this->assertEquals('updated_widget', $context['widget_container']);
     $this->assertEquals('updated_id', $context->data()->getIdentifier('widget_id'));
     $this->assertEquals('updated_widget_id', $context->data()->get('widget_id'));
 }
开发者ID:woei66,项目名称:platform,代码行数:15,代码来源:WidgetContextConfiguratorTest.php

示例10: testPreRenderAjaxFormWithQueryOptions

 /**
  * @covers ::preRenderAjaxForm
  */
 public function testPreRenderAjaxFormWithQueryOptions()
 {
     $request = Request::create('/test');
     $request->query->set('foo', 'bar');
     $this->requestStack->push($request);
     $prophecy = $this->prophesize('Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $url = '/test?foo=bar&other=query&ajax_form=1';
     $prophecy->generateFromRoute('<current>', [], ['query' => ['foo' => 'bar', 'other' => 'query', FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]], TRUE)->willReturn((new GeneratedUrl())->setCacheContexts(['route'])->setGeneratedUrl($url));
     $url_generator = $prophecy->reveal();
     $this->container->set('url_generator', $url_generator);
     $element = ['#type' => 'select', '#id' => 'test', '#ajax' => ['wrapper' => 'foo', 'callback' => 'test-callback', 'options' => ['query' => ['other' => 'query']]]];
     $element = RenderElement::preRenderAjaxForm($element);
     $this->assertTrue($element['#ajax_processed']);
     $this->assertEquals($url, $element['#attached']['drupalSettings']['ajax']['test']['url']);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:18,代码来源:RenderElementTest.php

示例11: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->formCache = $this->getMock('Drupal\\Core\\Form\\FormCacheInterface');
     $this->cache = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
     $this->urlGenerator = $this->getMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
     $this->classResolver = $this->getClassResolverStub();
     $this->elementInfo = $this->getMockBuilder('\\Drupal\\Core\\Render\\ElementInfoManagerInterface')->disableOriginalConstructor()->getMock();
     $this->elementInfo->expects($this->any())->method('getInfo')->will($this->returnCallback(array($this, 'getInfo')));
     $this->csrfToken = $this->getMockBuilder('Drupal\\Core\\Access\\CsrfTokenGenerator')->disableOriginalConstructor()->getMock();
     $this->kernel = $this->getMockBuilder('\\Drupal\\Core\\DrupalKernel')->disableOriginalConstructor()->getMock();
     $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
     $this->themeManager = $this->getMock('Drupal\\Core\\Theme\\ThemeManagerInterface');
     $this->request = new Request();
     $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->requestStack = new RequestStack();
     $this->requestStack->push($this->request);
     $this->logger = $this->getMock('Drupal\\Core\\Logger\\LoggerChannelInterface');
     $form_error_handler = $this->getMock('Drupal\\Core\\Form\\FormErrorHandlerInterface');
     $this->formValidator = $this->getMockBuilder('Drupal\\Core\\Form\\FormValidator')->setConstructorArgs([$this->requestStack, $this->getStringTranslationStub(), $this->csrfToken, $this->logger, $form_error_handler])->setMethods(NULL)->getMock();
     $this->formSubmitter = $this->getMockBuilder('Drupal\\Core\\Form\\FormSubmitter')->setConstructorArgs(array($this->requestStack, $this->urlGenerator))->setMethods(array('batchGet', 'drupalInstallationAttempted'))->getMock();
     $this->root = dirname(dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__))));
     $this->formBuilder = new FormBuilder($this->formValidator, $this->formSubmitter, $this->formCache, $this->moduleHandler, $this->eventDispatcher, $this->requestStack, $this->classResolver, $this->elementInfo, $this->themeManager, $this->csrfToken);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:FormTestBase.php

示例12: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request)
 {
     try {
         $event = new RequestEvent('request', $this);
         $this->stack->push($request);
         $this->events->trigger($event, [$request]);
         if ($event->hasResponse()) {
             $response = $event->getResponse();
         } else {
             $response = $this->handleController();
         }
         return $this->handleResponse($response);
     } catch (\Exception $e) {
         return $this->handleException($e);
     }
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:19,代码来源:HttpKernel.php

示例13: createRequestStack

 /**
  * @return RequestStack
  */
 private function createRequestStack()
 {
     $request = Request::create('/');
     $requestStack = new RequestStack();
     $requestStack->push($request);
     return $requestStack;
 }
开发者ID:netdudes,项目名称:IgorwFileServeBundle,代码行数:10,代码来源:SendfileResponseFactoryTest.php

示例14: setUp

 protected function setUp()
 {
     /**
      * Add the test type to the factory and
      * the form to the container
      */
     $factory = new FormFactoryBuilder();
     $factory->addExtension(new CoreExtension());
     $factory->addType(new TestType());
     /**
      * Construct the container
      */
     $container = new Container();
     $container->set("thelia.form_factory_builder", $factory);
     $container->set("thelia.translator", new Translator($container));
     $container->setParameter("thelia.parser.forms", $definition = array("test_form" => "Thelia\\Tests\\Resources\\Form\\TestForm"));
     $request = new Request();
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $request->setSession(new Session(new MockArraySessionStorage()));
     $container->set("request", $request);
     $container->set("request_stack", $requestStack);
     $container->set("thelia.forms.validator_builder", new ValidatorBuilder());
     $container->set("event_dispatcher", new EventDispatcher());
     $this->factory = new TheliaFormFactory($requestStack, $container, $definition);
 }
开发者ID:vigourouxjulien,项目名称:thelia,代码行数:26,代码来源:TheliaFormFactoryTest.php

示例15: testOnPageContext

 /**
  * @covers ::onPageContext
  */
 public function testOnPageContext()
 {
     $collection = new RouteCollection();
     $route_provider = $this->prophesize(RouteProviderInterface::class);
     $route_provider->getRoutesByPattern('/test_route')->willReturn($collection);
     $request = new Request();
     $request_stack = new RequestStack();
     $request_stack->push($request);
     $data_definition = new DataDefinition(['type' => 'entity:user']);
     $typed_data = $this->prophesize(TypedDataInterface::class);
     $this->typedDataManager->getDefaultConstraints($data_definition)->willReturn([]);
     $this->typedDataManager->create($data_definition, 'banana')->willReturn($typed_data->reveal());
     $this->typedDataManager->createDataDefinition('bar')->will(function () use($data_definition) {
         return $data_definition;
     });
     $page = $this->prophesize(PageInterface::class);
     $this->executable->expects($this->once())->method('getPage')->will($this->returnValue($page->reveal()));
     $page->getPath()->willReturn('/test_route');
     $this->executable->expects($this->at(1))->method('addContext')->with('foo', $this->isInstanceOf(Context::class));
     $this->executable->expects($this->at(2))->method('addContext')->with('baz', $this->isInstanceOf(Context::class));
     $collection->add('test_route', new Route('/test_route', [], [], ['parameters' => ['foo' => ['type' => 'bar'], 'baz' => ['type' => 'bop'], 'page' => ['type' => 'entity:page']]]));
     // Set up a request with one of the expected parameters as an attribute.
     $request->attributes->add(['foo' => 'banana']);
     $route_param_context = new RouteParamContext($route_provider->reveal(), $request_stack);
     $route_param_context->onPageContext($this->event);
 }
开发者ID:pulibrary,项目名称:recap,代码行数:29,代码来源:RouteParamContextTest.php


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