當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::hasPreviousSession方法代碼示例

本文整理匯總了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 [];
 }
開發者ID:KasaiDot,項目名稱:FoolFrame,代碼行數:12,代碼來源:Notices.php

示例2: __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

示例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;
 }
開發者ID:kuczek,項目名稱:FOSJsRoutingBundle,代碼行數:32,代碼來源:Controller.php

示例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)));
 }
開發者ID:nveid,項目名稱:FOSJsRoutingBundle,代碼行數:28,代碼來源:Controller.php

示例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);
     }
 }
開發者ID:axelvnk,項目名稱:KunstmaanBundlesCMS,代碼行數:16,代碼來源:HostOverrideCleanupHandler.php

示例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;
 }
開發者ID:symbb,項目名稱:symbb,代碼行數:26,代碼來源:XmlrpcController.php

示例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"));
 }
開發者ID:CG77,項目名稱:ezpublish-kernel,代碼行數:24,代碼來源:Session.php

示例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));
     }
 }
開發者ID:zomars,項目名稱:bolt,代碼行數:21,代碼來源:GeneralListener.php

示例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));
     }
 }
開發者ID:d-m-,項目名稱:bolt,代碼行數:18,代碼來源:GeneralListener.php

示例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);
     }
 }
開發者ID:parenthesislab,項目名稱:ParenthesisWPBundle,代碼行數:16,代碼來源:WordpressRequestListener.php

示例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();
     }
 }
開發者ID:rfc1483,項目名稱:blog,代碼行數:14,代碼來源:RequestListener.php

示例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;
 }
開發者ID:visionappscz,項目名稱:JMSI18nRoutingBundle,代碼行數:43,代碼來源:DefaultLocaleResolver.php

示例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());
 }
開發者ID:anderson-abc,項目名稱:sf2_kowee,代碼行數:9,代碼來源:RequestTest.php

示例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());
 }
開發者ID:neokensou,項目名稱:symfony,代碼行數:9,代碼來源:RequestTest.php


注:本文中的Symfony\Component\HttpFoundation\Request::hasPreviousSession方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。