本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::hasPreviousSession方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::hasPreviousSession方法的具体用法?PHP Request::hasPreviousSession怎么用?PHP Request::hasPreviousSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::hasPreviousSession方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFlash
/**
* Get the flash notices
*
* @return array The flash notices, can be empty
*/
public function getFlash()
{
if ($this->request->hasPreviousSession()) {
return $this->request->getSession()->getFlashBag()->get('notice', []);
}
return [];
}
示例2: __construct
/**
* Runner constructor.
*/
public function __construct()
{
static::$request = Request::createFromGlobals();
if (!static::$request->hasPreviousSession()) {
$session = new Session();
$session->start();
static::$request->setSession($session);
}
}
示例3: indexAction
/**
* indexAction action.
*/
public function indexAction(Request $request, $_format)
{
$session = $request->getSession();
if ($request->hasPreviousSession() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
$cache = new ConfigCache($this->exposedRoutesExtractor->getCachePath($request->getLocale()), $this->debug);
if (!$cache->isFresh()) {
$exposedRoutes = $this->exposedRoutesExtractor->getRoutes();
$serializedRoutes = $this->serializer->serialize($exposedRoutes, 'json');
$cache->write($serializedRoutes, $this->exposedRoutesExtractor->getResources());
} else {
$serializedRoutes = file_get_contents((string) $cache);
$exposedRoutes = $this->serializer->deserialize($serializedRoutes, 'Symfony\\Component\\Routing\\RouteCollection', 'json');
}
$routesResponse = new RoutesResponse($this->exposedRoutesExtractor->getBaseUrl(), $exposedRoutes, $this->exposedRoutesExtractor->getPrefix($request->getLocale()), $this->exposedRoutesExtractor->getHost(), $this->exposedRoutesExtractor->getScheme(), $request->getLocale());
$content = $this->serializer->serialize($routesResponse, 'json');
if (null !== ($callback = $request->query->get('callback'))) {
$validator = new \JsonpCallbackValidator();
if (!$validator->validate($callback)) {
throw new HttpException(400, 'Invalid JSONP callback value');
}
$content = $callback . '(' . $content . ');';
}
$response = new Response($content, 200, array('Content-Type' => $request->getMimeType($_format)));
$this->cacheControlConfig->apply($response);
return $response;
}
示例4: indexAction
/**
* indexAction action.
*/
public function indexAction(Request $request, $_format)
{
if (version_compare(strtolower(Kernel::VERSION), '2.1.0-dev', '<')) {
if (null !== ($session = $request->getSession())) {
// keep current flashes for one more request
$session->setFlashes($session->getFlashes());
}
} else {
$session = $request->getSession();
if ($request->hasPreviousSession() && $session->getFlashBag() instanceof AutoExpireFlashBag) {
// keep current flashes for one more request if using AutoExpireFlashBag
$session->getFlashBag()->setAll($session->getFlashBag()->peekAll());
}
}
$cache = new ConfigCache($this->cacheDir . '/fosJsRouting.json', $this->debug);
if (!$cache->isFresh()) {
$content = $this->serializer->serialize(new RoutesResponse($this->exposedRoutesExtractor->getBaseUrl(), $this->exposedRoutesExtractor->getRoutes()), 'json');
$cache->write($content, $this->exposedRoutesExtractor->getResources());
}
$content = file_get_contents((string) $cache);
if ($callback = $request->query->get('callback')) {
$content = $callback . '(' . $content . ');';
}
return new Response($content, 200, array('Content-Type' => $request->getMimeType($_format)));
}
示例5: logout
/**
* This method is called by the LogoutListener when a user has requested
* to be logged out. Usually, you would unset session variables, or remove
* cookies, etc.
*
* @param Request $request
* @param Response $response
* @param TokenInterface $token
*/
public function logout(Request $request, Response $response, TokenInterface $token)
{
// Remove host override
if ($request->hasPreviousSession() && $request->getSession()->has(DomainConfiguration::OVERRIDE_HOST)) {
$request->getSession()->remove(DomainConfiguration::OVERRIDE_HOST);
}
}
示例6: indexAction
public function indexAction(Request $request)
{
$this->get('monolog.logger.tapatalk')->debug('############################');
$this->get('monolog.logger.tapatalk')->debug('Current User:' . $this->get('symbb.core.user.manager')->getCurrentUser()->getUsername());
$this->get('monolog.logger.tapatalk')->debug("Has Session: " . $request->hasPreviousSession());
foreach ($request->headers as $name => $param) {
$this->get('monolog.logger.tapatalk')->debug("Request Header (" . $name . "): " . implode(", ", $param));
}
$server = new \Zend\XmlRpc\Server();
$server->setReturnResponse(true);
$server->setClass($this->get('symbb.extension.tapatalk.manager.call'));
$responseZend = $server->handle();
// error case
if ($responseZend instanceof \Zend\XmlRpc\Fault) {
$sfResponse = new \Symfony\Component\HttpFoundation\Response();
$sfResponse->headers->set('Content-Type', 'text/xml; charset=UTF-8');
$sfResponse->setContent($responseZend->saveXml());
} else {
$sfResponse = $responseZend->getReturnValue();
}
$sfResponse = $this->addResponseHeader($sfResponse);
foreach ($sfResponse->headers as $name => $param) {
$this->get('monolog.logger.tapatalk')->debug("Response Header (" . $name . "): " . implode(", ", $param));
}
return $sfResponse;
}
示例7: onBuildKernelHandler
/**
* Adds the session settings to the parameters that will be injected
* into the legacy kernel
*
* @param \eZ\Publish\Core\MVC\Legacy\Event\PreBuildKernelEvent $event
*/
public function onBuildKernelHandler(PreBuildKernelEvent $event)
{
$sessionInfos = array('configured' => false, 'started' => false, 'name' => false, 'namespace' => false, 'has_previous' => false, 'storage' => false);
if (isset($this->session)) {
$sessionInfos['configured'] = true;
$sessionInfos['name'] = $this->session->getName();
$sessionInfos['started'] = $this->session->isStarted();
$sessionInfos['namespace'] = $this->sessionStorageKey;
$sessionInfos['has_previous'] = isset($this->request) ? $this->request->hasPreviousSession() : false;
$sessionInfos['storage'] = $this->sessionStorage;
}
$legacyKernelParameters = $event->getParameters();
$legacyKernelParameters->set('session', $sessionInfos);
// Deactivate session cookie settings in legacy kernel.
// This will force using settings defined in Symfony.
$sessionSettings = array('site.ini/Session/CookieTimeout' => false, 'site.ini/Session/CookiePath' => false, 'site.ini/Session/CookieDomain' => false, 'site.ini/Session/CookieSecure' => false, 'site.ini/Session/CookieHttponly' => false);
$legacyKernelParameters->set("injected-settings", $sessionSettings + (array) $legacyKernelParameters->get("injected-settings"));
}
示例8: mailConfigCheck
/**
* No Mail transport has been set. We should gently nudge the user to set
* the mail configuration.
*
* For now, we only pester the user, if an extension needs to be able to
* send mail, but it's not been set up.
*
* @see: the issue at https://github.com/bolt/bolt/issues/2908
*
* @param Request $request
*/
protected function mailConfigCheck(Request $request)
{
if (!$request->hasPreviousSession()) {
return;
}
if ($this->app['users']->getCurrentuser() && !$this->app['config']->get('general/mailoptions') && $this->app['extensions']->hasMailSenders()) {
$error = "One or more installed extensions need to be able to send email. Please set up the 'mailoptions' in config.yml.";
$this->app['logger.flash']->error(Trans::__($error));
}
}
示例9: mailConfigCheck
/**
* No mail transport has been set. We should gently nudge the user to set
* the mail configuration.
*
* @see https://github.com/bolt/bolt/issues/2908
*
* @param Request $request
*/
protected function mailConfigCheck(Request $request)
{
if (!$request->hasPreviousSession()) {
return;
}
if (!$this->app['config']->get('general/mailoptions') && $this->app['users']->getCurrentuser() && $this->app['users']->isAllowed('files:config')) {
$error = "The mail configuration parameters have not been set up. This may interfere with password resets, and extension functionality. Please set up the 'mailoptions' in config.yml.";
$this->app['logger.flash']->error(Trans::__($error));
}
}
示例10: checkAuthentication
/**
* Checks if a Wordpress user is authenticated and authenticate him into Symfony security context.
*
* @param Request $request
*/
protected function checkAuthentication(Request $request)
{
if (!$request->hasPreviousSession()) {
return;
}
$session = $request->getSession();
if ($session->has('token')) {
$token = $session->get('token');
$this->tokenStorage->setToken($token);
}
}
示例11: initializeSession
protected function initializeSession(Request $request, $master)
{
if (!$master) {
return;
}
// inject the session object if none is present
if (null === $request->getSession() && $this->container->has('session')) {
$request->setSession($this->container->get('session'));
}
// starts the session if a session cookie already exists in the request...
if ($request->hasPreviousSession()) {
$request->getSession()->start();
}
}
示例12: resolveLocale
/**
* {@inheritDoc}
*/
public function resolveLocale(Request $request, array $availableLocales)
{
if ($this->hostMap && isset($this->hostMap[$host = $request->getHost()])) {
return $this->hostMap[$host];
}
// if a locale has been specifically set as a query parameter, use it
if ($request->query->has('hl')) {
$hostLanguage = $request->query->get('hl');
if (preg_match('#^[a-z]{2}(?:_[a-z]{2})?$#i', $hostLanguage)) {
return $hostLanguage;
}
}
// check if a session exists, and if it contains a locale
if ($request->hasPreviousSession()) {
$session = $request->getSession();
if ($session->has('_locale')) {
return $session->get('_locale');
}
}
// if user sends a cookie, use it
if ($request->cookies->has($this->cookieName)) {
$hostLanguage = $request->cookies->get($this->cookieName);
if (preg_match('#^[a-z]{2}(?:_[a-z]{2})?$#i', $hostLanguage)) {
return $hostLanguage;
}
}
// use accept header for locale matching if sent
if ($languages = $request->getLanguages()) {
foreach ($languages as $lang) {
if (in_array($lang, $availableLocales, true)) {
return $lang;
}
$langShort = explode('_', $lang)[0];
if (in_array($langShort, $availableLocales, true)) {
return $langShort;
}
}
}
return null;
}
示例13: testHasPreviousSession
public function testHasPreviousSession()
{
$request = new Request();
$this->assertFalse($request->hasPreviousSession());
$request->cookies->set('MOCKSESSID', 'foo');
$this->assertFalse($request->hasPreviousSession());
$request->setSession(new Session(new MockArraySessionStorage()));
$this->assertTrue($request->hasPreviousSession());
}
示例14: testHasPreviousSession
public function testHasPreviousSession()
{
$request = new Request();
$this->assertFalse($request->hasPreviousSession());
$request->cookies->set(session_name(), 'foo');
$this->assertFalse($request->hasPreviousSession());
$request->setSession(new Session(new ArraySessionStorage()));
$this->assertTrue($request->hasPreviousSession());
}