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


PHP Request::setSession方法代码示例

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


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

示例1: setFlash

 /**
  * Sets a flash notice
  *
  * @param  string  $level    The level of the message: success, warning, danger
  * @param  string  $message  The message
  */
 public function setFlash($level, $message)
 {
     if (!$this->request->hasSession()) {
         $this->request->setSession(new Session());
     }
     $this->flash_notices[] = ['level' => $level, 'message' => $message];
     $this->request->getSession()->getFlashBag()->set('notice', $this->flash_notices);
 }
开发者ID:KasaiDot,项目名称:FoolFrame,代码行数:14,代码来源:Notices.php

示例2: setUp

 public function setUp()
 {
     $this->request = new Request();
     $storage = new \Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage();
     $session = new \Symfony\Component\HttpFoundation\Session\Session($storage);
     $this->request->setSession($session);
     $this->tokenProcessor = TokenProcessor::getInstance();
 }
开发者ID:cammanderson,项目名称:phruts,代码行数:8,代码来源:TokenProcessorTest.php

示例3: __construct

 /**
  * Runner constructor.
  */
 public function __construct()
 {
     static::$request = Request::createFromGlobals();
     if (!static::$request->hasPreviousSession()) {
         $session = new Session();
         $session->start();
         static::$request->setSession($session);
     }
 }
开发者ID:spasquier,项目名称:sv-egg-giver,代码行数:12,代码来源:Runner.php

示例4: setup

 public function setup()
 {
     $this->requestStack = new RequestStack();
     $this->session = $this->prophesize('Symfony\\Component\\HttpFoundation\\Session\\SessionInterface');
     $this->provider = $this->prophesize('League\\OAuth2\\Client\\Provider\\AbstractProvider');
     $this->request = new Request();
     $this->request->setSession($this->session->reveal());
     $this->requestStack->push($this->request);
 }
开发者ID:knpuniversity,项目名称:oauth2-client-bundle,代码行数:9,代码来源:OAuth2ClientTest.php

示例5: setUp

 protected function setUp()
 {
     $this->action = new \Phruts\Action\Action();
     $this->actionKernel = $this->getMockBuilder('\\Phruts\\Action\\ActionKernel')->disableOriginalConstructor()->getMock();
     $this->action->setActionKernel($this->actionKernel);
     $this->request = new \Symfony\Component\HttpFoundation\Request();
     $storage = new \Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage();
     $session = new \Symfony\Component\HttpFoundation\Session\Session($storage);
     //        $session = $this->getMockBuilder('Symfony\Component\HttpFoundation\Session\Session')->disableOriginalConstructor()->getMock();
     $this->request->setSession($session);
 }
开发者ID:cammanderson,项目名称:phruts,代码行数:11,代码来源:ActionTest.php

示例6: runSessionOnKernelResponse

    protected function runSessionOnKernelResponse($newToken, $original = null)
    {
        $session = new Session(new ArraySessionStorage());

        if ($original !== null) {
            $session->set('_security_session', $original);
        }

        $this->securityContext->setToken($newToken);

        $request = new Request();
        $request->setSession($session);

        $event = new FilterResponseEvent(
            $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
            $request,
            HttpKernelInterface::MASTER_REQUEST,
            new Response()
        );

        $listener = new ContextListener($this->securityContext, array(), 'session');
        $listener->onKernelResponse($event);

        return $session;
    }
开发者ID:usefulthink,项目名称:symfony,代码行数:25,代码来源:ContextListenerTest.php

示例7: createSession

 protected function createSession(Request $request)
 {
     $session = new Session();
     $request->setSession($session);
     $session->setName('sitegear.test');
     return $session;
 }
开发者ID:sitegear,项目名称:sitegear,代码行数:7,代码来源:TestEngine.php

示例8: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     // always set the session onto the request object.
     $request->setSession($this->session);
     // we only need to manage the session for the master request.
     // subrequests will have the session available anyways, but we will
     // be closing and setting the cookie for the master request only.
     if ($type !== HttpKernelInterface::MASTER_REQUEST) {
         return $this->kernel->handle($request, $type, $catch);
     }
     // the session may have been manually started before the middleware is
     // invoked - in this case, we cross our fingers and hope the session has
     // properly initialised itself
     if (!$this->session->isStarted()) {
         $this->initSession($request);
     }
     $response = $this->kernel->handle($request, $type, $catch);
     // if the session has started, save it and attach the session cookie. if
     // the session has not started, there is nothing to save and there is no
     // point in attaching a cookie to persist it.
     if ($this->session->isStarted()) {
         $this->closeSession($request, $response);
     }
     return $response;
 }
开发者ID:autarky,项目名称:framework,代码行数:28,代码来源:SessionMiddleware.php

示例9: createEvent

 protected function createEvent(\Exception $e)
 {
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\KernelInterface');
     $request = new Request();
     $request->setSession($this->session);
     $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $e);
     return $event;
 }
开发者ID:xtrasmal,项目名称:iinano,代码行数:8,代码来源:AccessDeniedListenerTest.php

示例10: _initNativeSession

 public function _initNativeSession(Request $request)
 {
     if (!$request->hasSession()) {
         $sesOption = array('cache_limiter' => 'nocache', 'cookie_domain' => 'localhost.com', 'cookie_httponly' => '1', 'cookie_lifetime' => '1800', 'cookie_path' => '/', 'cookie_secure' => '0', 'entropy_file' => '/dev/urandom', 'entropy_length' => '1024', 'gc_divisor' => '100', 'gc_maxlifetime' => '1800', 'gc_probability' => '100', 'hash_bits_per_character' => '4', 'hash_function' => '1', 'name' => 'NODEPHP', 'referer_check' => '', 'serialize_handler' => 'php', 'use_cookies' => '1', 'use_only_cookies' => '1', 'use_trans_sid' => '0', 'upload_progress.enabled' => '1', 'upload_progress.cleanup' => '1', 'upload_progress.prefix' => 'upload_progress_', 'upload_progress.name' => 'PHP_SESSION_UPLOAD_PROGRESS', 'upload_progress.freq' => '1%', 'upload_progress.min-freq' => '1', 'url_rewriter.tags' => 'a=href,area=href,frame=src,form=,fieldset=');
         $session = new Session(new NativeSessionStorage($sesOption, new NativeFileSessionHandler('/tmp;/tmp'), new MetadataBag('nodephp_meta')), new AttributeBag('nodephp_attributes'), new FlashBag('nodephp_flashes'));
         $request->setSession($session);
     }
 }
开发者ID:renyunhuang,项目名称:nodephp,代码行数:8,代码来源:SessionManger.php

示例11: __construct

 public function __construct(Request $request, $openPlatformAppId, $openPlatformToken, $clientId, $clientSecret, $redirectUrl = null)
 {
     $session = new Session();
     $request->setSession($session);
     parent::__construct($request, new \Overtrue\Socialite\Config([]), $clientId, $clientSecret, $redirectUrl);
     $this->openPlatformAppId = $openPlatformAppId;
     $this->openPlatformToken = $openPlatformToken;
 }
开发者ID:takatost,项目名称:wechat_open_platform,代码行数:8,代码来源:WeChatProvider.php

示例12: Session

 /**
  * @param \Symfony\Component\Security\Core\Authentication\Token\TokenInterface $token
  */
 function it_should_return_the_correct_redirect_response_after_authentication_success($token)
 {
     $session = new Session();
     $this->request->setSession($session);
     $this->onAuthenticationSuccess($this->request, $token, 'foo')->getTargetUrl()->shouldEqual('/');
     $session->set('_security.main.target_path', '/foo');
     $this->onAuthenticationSuccess($this->request, $token, 'foo')->getTargetUrl()->shouldEqual('/foo');
 }
开发者ID:ldaptools,项目名称:ldaptools-bundle,代码行数:11,代码来源:LdapGuardAuthenticatorSpec.php

示例13: getContainer

 /**
  * Creates a Container with a Session-containing Request service.
  *
  * @return Container
  */
 protected function getContainer()
 {
     $container = new Container();
     $request = new Request();
     $session = new Session(new ArraySessionStorage());
     $request->setSession($session);
     $container->set('request', $request);
     return $container;
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:14,代码来源:PhpEngineTest.php

示例14: testLegacyWithLoginUrl

 /**
  * @group legacy
  */
 public function testLegacyWithLoginUrl()
 {
     $request = new Request();
     $request->setSession($this->getMock('Symfony\\Component\\HttpFoundation\\Session\\Session'));
     $authenticator = new LegacyFormLoginAuthenticator();
     /** @var RedirectResponse $actualResponse */
     $actualResponse = $authenticator->onAuthenticationSuccess($request, $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'), 'provider_key');
     $this->assertEquals('/default_url', $actualResponse->getTargetUrl());
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:12,代码来源:AbstractFormLoginAuthenticatorTest.php

示例15: filterResponse

 private function filterResponse(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
 {
     $request->setSession($this->session);
     $response = new Response();
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $event = new FilterResponseEvent($kernel, $request, $type, $response);
     $this->listener->onKernelResponse($event);
     $this->assertSame($response, $event->getResponse());
 }
开发者ID:nightchiller,项目名称:symfony,代码行数:9,代码来源:TestSessionListenerTest.php


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