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


PHP Session::has方法代碼示例

本文整理匯總了PHP中Symfony\Component\HttpFoundation\Session\Session::has方法的典型用法代碼示例。如果您正苦於以下問題:PHP Session::has方法的具體用法?PHP Session::has怎麽用?PHP Session::has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\HttpFoundation\Session\Session的用法示例。


在下文中一共展示了Session::has方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getSessionToken

 /**
  * {@inheritdoc}
  */
 protected function getSessionToken()
 {
     if (!$this->session->has($this->name)) {
         $this->session->set($this->name, sha1(uniqid(rand(), true)));
     }
     return $this->session->get($this->name);
 }
開發者ID:jacobjjc,項目名稱:PageKit-framework,代碼行數:10,代碼來源:SessionCsrfProvider.php

示例2: get

 /**
  * @param $name
  * @return Filter
  */
 public function get($name, $reset = false)
 {
     if (!$this->session->has('filter_' . $name) || $reset) {
         $this->session->set('filter_' . $name, new Filter());
     }
     return $this->session->get('filter_' . $name);
 }
開發者ID:jaapjansma,項目名稱:homefinance,代碼行數:11,代碼來源:FilterBag.php

示例3: getChoices

 /**
  *
  * @return array
  */
 public function getChoices()
 {
     if ($this->sessionManager->has('choices')) {
         return $this->sessionManager->get('choices');
     }
     return [];
 }
開發者ID:e-ReColNat,項目名稱:recolnat-diff,代碼行數:11,代碼來源:SessionHandler.php

示例4: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->session->has('_locale')) {
         $event->getRequest()->setLocale($this->session->get('_locale'));
         $this->translator->setLocale($this->session->get('_locale'));
     }
 }
開發者ID:ChrisdAutume,項目名稱:EtuUTT,代碼行數:10,代碼來源:LocaleListener.php

示例5: __construct

 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $this->emFrom = $this->doctrine->getManager($this->parameters->getManagerFrom());
     $this->emTo = $this->doctrine->getManager($this->parameters->getManagerTo());
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     //$toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo() );
     //$toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever);
     //$this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever);
     if ($this->session->has(CompareStructure::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         throw new SyncException('No source data');
     }
     /*if($this->session->has(CompareStructure::SESSION_TO_KEY)){
           $this->toAnalyzer->setSchemas($this->session->get(CompareStructure::SESSION_TO_KEY));
           $this->toAnalyzer->initTables();
       }else{
           throw new SyncException('No targeted data');
       }*/
 }
開發者ID:rombar3,項目名稱:PgExplorer,代碼行數:27,代碼來源:SyncData.php

示例6: __construct

 /**
  * @param Registry $doctrine
  * @param Session $session
  * @param Logger $logger
  * @param Parameters $parameters
  */
 public function __construct(Registry $doctrine, Session $session, Logger $logger, Parameters $parameters)
 {
     $this->doctrine = $doctrine;
     $this->session = $session;
     $this->logger = $logger;
     $this->parameters = $parameters;
     $fromRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $fromRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $fromMassRetriever = new PgMassRetriever($doctrine, $this->logger, $this->parameters->getManagerFrom());
     $toRetriever = new PgRetriever($doctrine, $this->logger, $this->parameters->getManagerTo());
     $toRetriever->setIndexType(PgRetriever::INDEX_TYPE_NAME);
     $toMassRetriever = new PgMassRetriever($doctrine, $this->logger, $this->parameters->getManagerTo());
     $this->fromAnalyzer = new PgAnalyzer($this->logger, $fromRetriever, $fromMassRetriever);
     $this->toAnalyzer = new PgAnalyzer($this->logger, $toRetriever, $toMassRetriever);
     if ($this->session->has(SyncHandler::SESSION_FROM_KEY)) {
         $this->fromAnalyzer->setSchemas($this->session->get(SyncHandler::SESSION_FROM_KEY));
         $this->fromAnalyzer->initTables();
     } else {
         $this->fromAnalyzer->initSchemas();
         $this->fromAnalyzer->initSchemasElements();
         $this->fromAnalyzer->initCompareTableInfo();
         //$this->session->set(SyncHandler::SESSION_FROM_KEY, $this->fromAnalyzer->getSchemas());
     }
     if ($this->session->has(SyncHandler::SESSION_TO_KEY)) {
         $this->toAnalyzer->setSchemas($this->session->get(SyncHandler::SESSION_TO_KEY));
         $this->toAnalyzer->initTables();
     } else {
         $this->toAnalyzer->initSchemas();
         $this->toAnalyzer->initSchemasElements();
         $this->toAnalyzer->initCompareTableInfo();
         $this->toAnalyzer->initTables();
         //$this->session->set(SyncHandler::SESSION_TO_KEY, $this->toAnalyzer->getSchemas());
     }
 }
開發者ID:rombar3,項目名稱:PgExplorer,代碼行數:40,代碼來源:CompareStructure.php

示例7: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     $token = $this->context->getToken();
     if (is_null($token)) {
         return;
     }
     $_route = $event->getRequest()->attributes->get('_route');
     if ($this->context->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         if (!$token->getUser() instanceof PersonInterface) {
             // We don't have a PersonInterface... Nothing to do here.
             return;
         }
         if ($_route == 'lc_home' || $_route == 'fos_user_security_login') {
             $key = '_security.main.target_path';
             #where "main" is your firewall name
             //check if the referer session key has been set
             if ($this->session->has($key)) {
                 //set the url based on the link they were trying to access before being authenticated
                 $url = $this->session->get($key);
                 //remove the session key
                 $this->session->remove($key);
             } else {
                 $url = $this->router->generate('lc_dashboard');
             }
             $event->setResponse(new RedirectResponse($url));
         } else {
             $this->checkUnconfirmedEmail();
         }
     }
 }
開發者ID:hacklabr,項目名稱:login-cidadao,代碼行數:34,代碼來源:LoggedInUserListener.php

示例8: getCurrentSite

 public function getCurrentSite(Request $request)
 {
     $currentSite = null;
     $siteId = $request->get('site');
     if (!$siteId && $this->session->has(self::SESSION_NAME)) {
         $currentSiteId = $this->session->get(self::SESSION_NAME);
         $currentSite = $this->siteManager->find($currentSiteId);
         if (!$currentSite) {
             $sites = $this->getSites();
             if (count($sites) > 0) {
                 $currentSite = $this->getSites()[0];
             }
         }
     } else {
         foreach ($this->getSites() as $site) {
             if ($siteId && $site->getId() == $siteId) {
                 $currentSite = $site;
             } elseif (!$siteId && $site->getIsDefault()) {
                 $currentSite = $site;
             }
         }
         if (!$currentSite && count($this->sites) > 0) {
             $currentSite = $this->sites[0];
         }
     }
     if ($currentSite) {
         $this->session->set(self::SESSION_NAME, $currentSite->getId());
     }
     return $currentSite;
 }
開發者ID:symbio,項目名稱:orangegate4-page-bundle,代碼行數:30,代碼來源:SitePool.php

示例9: start

 /**
  * Start engine with given players or from session if players is not defined
  * @param Session $session
  * @param PlayerInterface $player1
  * @param PlayerInterface $player2
  * @param Board $board
  * @return EngineInterface|GameEngine|mixed
  * @throws \InvalidArgumentException if no players is defined in both arguments and session
  */
 public static function start(Session $session, PlayerInterface $player1 = null, PlayerInterface $player2 = null, Board $board = null)
 {
     if ((!$player1 || !$player2) && (!$session->has('player1') || !$session->has('player2'))) {
         throw new \InvalidArgumentException('You must specify players to start the engine');
     }
     //restart the game
     if ($player1 && $player2) {
         $session->set('player1', $player1);
         $session->set('player2', $player2);
         $board = new Board(array());
         $session->set('board', $board);
         self::$gameEngine = new GameEngine($session, $player1, $player2, $board);
         return self::$gameEngine;
     }
     if (self::$gameEngine) {
         return self::$gameEngine;
     }
     if (!$player1 || !$player2 && ($session->has('player1') && $session->has('player2'))) {
         $player1 = $session->get('player1');
         $player2 = $session->get('player2');
         $board = $session->get('board');
         $player1->setBoard($board);
         $player2->setBoard($board);
     }
     if (!$board) {
         $board = new Board(array());
     }
     self::$gameEngine = new GameEngine($session, $player1, $player2, $board);
     return self::$gameEngine;
 }
開發者ID:symstriker,項目名稱:tictactoe,代碼行數:39,代碼來源:GameEngine.php

示例10: testCanUnsetAVariable

 public function testCanUnsetAVariable()
 {
     $this->session->set('testUnset', 5);
     $this->assertEquals(5, $this->access->get('testUnset'));
     $this->access->remove('testUnset');
     $this->assertFalse($this->session->has('testUnset'));
     $this->assertFalse($this->access->has('testUnset'));
 }
開發者ID:deltasystems,項目名稱:dewdrop,代碼行數:8,代碼來源:AccessTest.php

示例11: isAuthenticated

 /**
  * Checks if the user is authenticated.
  *
  * @return bool True if the user is authenticated
  */
 public function isAuthenticated()
 {
     if (!$this->session->has('_auth_until') || $this->session->get('_auth_until') < time()) {
         return false;
     }
     // Update the expiration date
     $this->session->set('_auth_until', time() + $this->timeout);
     return true;
 }
開發者ID:burguin,項目名稱:test02,代碼行數:14,代碼來源:InstallToolUser.php

示例12: getAuthData

 /**
  * Try to get Session or Cookies identification data
  *
  * @return array
  */
 private function getAuthData()
 {
     if ($this->session->has($this->facade->domain)) {
         return unserialize($this->session->get($this->facade->domain));
     } elseif ($this->request->cookies->has($this->facade->domain)) {
         return $this->getCookie();
     }
     return [];
 }
開發者ID:eskrano,項目名稱:mobicms,代碼行數:14,代碼來源:Identification.php

示例13: validate

 /**
  * @param Request $request
  *
  * @return bool
  * @throws \Exception
  */
 public function validate($request)
 {
     $token = $request->request->get(self::SECURITY_TOKEN_NAME);
     if (!empty($token) && $this->session->has(self::SECURITY_TOKEN_NAME) && $this->session->get(self::SECURITY_TOKEN_NAME) == $token) {
         return true;
     }
     $sessionToken = $this->session->get(self::SECURITY_TOKEN_NAME);
     throw new \Exception(sprintf('Token is invalid or empty. Expects <<%s>> but gotten <<%s>>', $sessionToken, $token));
 }
開發者ID:rsmakota,項目名稱:ortofit_backoffice,代碼行數:15,代碼來源:SingUpSecurity.php

示例14: pullMessages

 public function pullMessages($parentRoute = null)
 {
     if ($this->session->has(Messages::$_MESSAGES_POOL_NAME)) {
         $poolOfMessages = $this->session->get(Messages::$_MESSAGES_POOL_NAME);
         $this->session->remove(Messages::$_MESSAGES_POOL_NAME);
     } else {
         $poolOfMessages = null;
     }
     return $poolOfMessages;
 }
開發者ID:tellaw,項目名稱:leadsfactory,代碼行數:10,代碼來源:Messages.php

示例15: oldInput

 /**
  * Loads input from the session, which has been persisted through the response class
  *
  * @return void
  * @author Dan Cox
  */
 public function oldInput()
 {
     if ($this->session->has('input\\old')) {
         $input = $this->session->get('input\\old');
         $type = $this->session->get('input\\old.type');
         $deobsfucated = unserialize(base64_decode($input));
         $this->putInput($deobsfucated, $type);
         $this->session->remove('input\\old');
         $this->session->remove('input\\old.type');
     }
 }
開發者ID:antoligy,項目名稱:Framework,代碼行數:17,代碼來源:Request.php


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