當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。