本文整理汇总了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);
}
示例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();
}
示例3: __construct
/**
* Runner constructor.
*/
public function __construct()
{
static::$request = Request::createFromGlobals();
if (!static::$request->hasPreviousSession()) {
$session = new Session();
$session->start();
static::$request->setSession($session);
}
}
示例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);
}
示例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);
}
示例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;
}
示例7: createSession
protected function createSession(Request $request)
{
$session = new Session();
$request->setSession($session);
$session->setName('sitegear.test');
return $session;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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');
}
示例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;
}
示例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());
}
示例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());
}