本文整理汇总了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);
}
示例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);
}
示例3: getChoices
/**
*
* @return array
*/
public function getChoices()
{
if ($this->sessionManager->has('choices')) {
return $this->sessionManager->get('choices');
}
return [];
}
示例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'));
}
}
示例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');
}*/
}
示例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());
}
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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'));
}
示例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;
}
示例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 [];
}
示例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));
}
示例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;
}
示例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');
}
}