本文整理汇总了PHP中Zend\Session\Container::offsetExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::offsetExists方法的具体用法?PHP Container::offsetExists怎么用?PHP Container::offsetExists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Session\Container
的用法示例。
在下文中一共展示了Container::offsetExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAuthData
/**
* @return object | null
*/
public function getAuthData()
{
if (!$this->sessionContainer->offsetExists('data')) {
return null;
}
return $this->sessionContainer->data;
}
示例2: authorize
/**
* @throws BadAuthenticationException
*/
public function authorize()
{
if (!$this->sessionContainer->offsetExists('data')) {
throw new BadAuthenticationException('You must be first authenticated');
}
$this->instagramWrapper->setAccessToken($this->sessionContainer->data);
}
示例3: has
/**
* Test if has datas with $uid key
* @param mixed $uid
* @return boolean
*/
public function has($uid)
{
if (null === $this->session) {
return false;
}
return $this->session->offsetExists($uid);
}
示例4: initAuth
public function initAuth(MvcEvent $e)
{
$matches = $e->getRouteMatch();
$controller = $matches->getParam('controller');
$action = $matches->getParam('action');
$sesion = new Container('reminderSesion');
// ¿Es el controlador de errores?
if ($controller === "Application\\Controller\\Error") {
// No valida permisos
return;
}
// No valida permisos
if ($action == "error") {
return;
}
// ¿es la página de Marketing?
if ($controller === "Application\\Controller\\Index" && in_array($action, array('index'))) {
// ¿Tiene una sesión activa ?
if ($sesion->offsetExists('user_username')) {
// Si se encuentra en la página de marketing y tiene una sesion activa
// se lo envia de regreso a la página principal
$matches->setParam("controller", "Application\\Controller\\Inicio");
$matches->setParam("action", "index");
// return;
} else {
// Si no tiene una sesion activa se lo deja permanecer en la página de marketing
return;
}
}
if ($controller === "Application\\Controller\\Admin" && in_array($action, array('colaborar'))) {
return;
}
// ¿es el login o se está autenticando ?
if ($controller === "Application\\Controller\\Login" && in_array($action, array('index', 'autenticar', 'logout'))) {
if ($action == "logout") {
return;
}
if ($sesion->offsetExists('user_username')) {
// Si se encuentra en la página de marketing y tiene una sesion activa
// se lo envia de regreso a la página principal
$matches->setParam("controller", "Application\\Controller\\Inicio");
$matches->setParam("action", "index");
// return;
} else {
// Si no tiene una sesion activa se lo deja permanecer en la página de marketing
return;
}
}
// var_dump($sesion->offsetExists('user_username'));exit();
// Si no hay acl con esto se valida que inicie sesión
if (!$sesion->offsetExists('user_username')) {
$matches->setParam("controller", "Application\\Controller\\Login");
$matches->setParam("action", "index");
return;
}
}
示例5: getPickingStationByID
public function getPickingStationByID($stationID)
{
$model = new PickingStationsModel($this->serviceLocator);
$station = $model->getPickingStationByID($stationID);
$session = new Container('warehouse');
$session->offsetSet('pickingStationID', $station[0]['ID']);
$session->offsetSet('pickingStationName', $station[0]['StationName']);
$session->offsetSet('pickingStationAlias', $station[0]['StationAlias']);
if ($session->offsetExists('pickingStationID') && $session->offsetExists('pickingStationName') && $session->offsetExists('pickingStationAlias')) {
return $station[0];
} else {
return false;
}
}
示例6: loginAction
public function loginAction()
{
// $crypt = new Cryptography\Service();
$form = new Login();
$request = $this->getRequest();
if ($request->isPost()) {
//Validate the form
$formValidator = new LoginValidator();
$form->setInputFilter($formValidator->getInputFilter());
$form->setData($request->getPost());
if ($form->isValid()) {
$formData = $form->getData();
// $dbAdapter = $this->authService->getAdapter();
$authAdapter = $this->authService->getAdapter();
$authAdapter->setIdentity($formData['email_address']);
$authAdapter->setCredential($formData['password']);
// Perform the authentication query, saving the result
$result = $this->authService->authenticate($authAdapter);
if ($result->isValid()) {
$data = $authAdapter->getResultRowObject(null, 'password');
$this->authService->getStorage()->write($data);
$sessionContainer = new Container('base');
$redirectUrl = $sessionContainer->offsetExists('lastRequest') ? $sessionContainer->offsetGet('lastRequest') : 'home';
return $this->redirect()->toRoute($redirectUrl);
}
}
$this->flashMessenger()->addErrorMessage('Validation failed');
}
$viewModel = new ViewModel(array('form' => $form, 'errorMessages' => $this->flashMessenger()->getErrorMessages(), 'successMessages' => $this->flashMessenger()->getCurrentSuccessMessages()));
// $viewModel->setTerminal(true-); //Remove this if you want your layout to be shown
return $viewModel;
}
示例7: onDispatch
public function onDispatch(MvcEvent $e)
{
/*
$admin_session = new Container('admin');
$username = $admin_session->username;
if(empty($username)) {
return $this->redirect()->toRoute('adminlogin');
}
*/
/* Set Default layout for all the actions */
$this->layout('layout/layout');
$em = $this->getEntityManager();
$cities = $em->getRepository('\\Admin\\Entity\\City')->findBy(array('countryId' => 2));
$categories = $em->getRepository('\\Admin\\Entity\\Categories')->findBy(array('status' => 1));
$signupForm = new Forms\SignupForm();
$loginForm = new Forms\LoginForm();
$forgotpassForm = new Forms\ForgotPasswordForm();
$this->layout()->signupForm = $signupForm;
$this->layout()->loginForm = $loginForm;
$this->layout()->forgotpassForm = $forgotpassForm;
$this->layout()->cities = $cities;
$this->layout()->categories = $categories;
$user_session = new Container('user');
$userid = $user_session->userId;
$city = "";
$searchSession = new Container("searchsess");
$searchType = "";
$searchTerm = "";
if ($searchSession->offsetExists("type")) {
$searchType = $searchSession->offsetGet("type");
$searchTerm = $searchSession->offsetGet("searchTerm");
}
if ($searchType == "category" && $searchTerm != "") {
$this->layout()->searchedCategory = $searchTerm;
}
if ($searchType == "city" && $searchTerm != "") {
$this->layout()->userCity = $searchTerm;
}
if (!empty($userid)) {
$msg = 'You are already logged in.';
$status = 1;
$this->layout()->setVariable('userId', $user_session->userId);
$this->layout()->setVariable('username', $user_session->userName);
$username = $user_session->userName;
$tmp_user = $em->getRepository('\\Admin\\Entity\\Users')->find($user_session->userId);
$city = $tmp_user->getCity();
if ($searchType == "city" && $searchTerm != "") {
$this->layout()->userCity = $searchTerm;
} else {
if (!empty($city)) {
$cityObj = $em->getRepository('\\Admin\\Entity\\City')->find($city);
$this->layout()->userCity = $cityObj->getCityName();
}
}
} else {
$this->layout()->setVariable('userId', '');
}
return parent::onDispatch($e);
}
示例8: onBootstrap
public function onBootstrap($e)
{
$e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) {
$controller = $e->getTarget();
$controllerClass = get_class($controller);
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
$config = $e->getApplication()->getServiceManager()->get('config');
if (isset($config['module_layouts'][$moduleNamespace])) {
$controller->layout($config['module_layouts'][$moduleNamespace]);
}
}, 100);
$session = new Container('base');
if (!$session->offsetExists('language')) {
if (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "es") {
$session->offsetSet('language', "es_ES");
} elseif (substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) == "en") {
$session->offsetSet('language', "en_US");
}
}
$e->getApplication()->getServiceManager()->get('translator')->setLocale($session->offsetGet('language'));
$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
示例9: boforeDispatch
/**
* Before Dispatch Function
*
* @param MvcEvent $event
*/
function boforeDispatch(MvcEvent $event)
{
$sm = $event->getApplication()->getServiceManager();
$config = $sm->get('Config');
$list = $config['whitelist'];
$name = $sm->get('request')->getUri()->getPath();
$controller = $event->getRouteMatch()->getParam('controller');
$action = $event->getRouteMatch()->getParam('action');
$session = new Container('User');
$controller = $event->getRouteMatch()->getParam('controller');
$action = $event->getRouteMatch()->getParam('action');
if (!(strpos($name, 'reset-password') || in_array($name, $list)) && $session->offsetExists('userId')) {
$serviceManager = $event->getApplication()->getServiceManager();
$roleTable = $serviceManager->get('RoleTable');
$userRoleTable = $serviceManager->get('UserRoleTable');
$roleID = $userRoleTable->getUserRoles('user_id = ' . $session->offsetGet('userId'), array('role_id'));
$roleName = $roleTable->getUserRoles('rid = ' . $roleID[0]['role_id'], array('role_name'));
$userRole = $roleName[0]['role_name'];
$acl = $serviceManager->get('Acl');
$acl->initAcl();
$status = $acl->isAccessAllowed($userRole, $controller, $action);
if (!$status) {
die('Permission denied');
}
}
}
示例10: getIdentityRoles
/**
* {@inheritDoc}
*/
public function getIdentityRoles()
{
$authService = $this->userService;
// $definedRoles = $this->config['role_providers']['BjyAuthorize\Provider\Role\Config']['user']['children'];
$roleKey = $this->config['ldap_role_key'];
// $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
// $definedRoles = $em->getRepository("ZfcUserLdap\Entity\Role")->findAll();
// var_dump($role);
// exit();
if (!$authService->getAuthService()->hasIdentity()) {
return array($this->getDefaultRole());
}
$session = new Container('ZfcUserLdap');
if (!$session->offsetExists('ldapObj')) {
return array($this->getDefaultRole());
}
// var_dump($roleKey);
$user = $session->offsetGet('ldapObj');
$roles = array();
// var_dump($user);
// var_dump($definedRoles);
// exit();
foreach ($user->getRoles() as $role) {
// if (isset($definedRoles[$role]))
$roles[] = $role->getRoleId();
}
return $roles;
// $session = new Container('ZfcUserLdap');
// $user = $session->offsetGet('ldapObj');
// $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
// // $Roles = $em->getRepository("ZfcUserLdap\Entity\User")->find();
// // var_dump($authService->getAuthService()->getIdentity());
// var_dump($user);
// exit();
}
示例11: offsetExists
/**
* {@inheritDoc}
*/
public function offsetExists($key)
{
if (!empty($this->sessionVars[$key])) {
return true;
}
return parent::offsetExists($key);
}
示例12: boforeDispatch
function boforeDispatch(MvcEvent $event)
{
$request = $event->getRequest();
$response = $event->getResponse();
$target = $event->getTarget();
/* Offline pages not needed authentication */
$whiteList = array('Auth\\Controller\\Auth-login', 'Auth\\Controller\\Auth-logout', 'Auth\\Controller\\Auth-signup');
$requestUri = $request->getRequestUri();
$controller = $event->getRouteMatch()->getParam('controller');
$action = $event->getRouteMatch()->getParam('action');
$requestedResourse = $controller . "-" . $action;
$session = new Container('User');
if ($session->offsetExists('email')) {
if (in_array($requestedResourse, $whiteList)) {
$url = '/TPWeb/public/produit';
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
$response->setStatusCode(302);
}
} else {
if (!in_array($requestedResourse, $whiteList)) {
$url = '/TPWeb/public/auth';
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
$response->setStatusCode(302);
}
$response->sendHeaders();
}
//print "Called before any controller action called. Do any operation.";
}
示例13: boforeDispatch
function boforeDispatch(MvcEvent $event)
{
$request = $event->getRequest();
$response = $event->getResponse();
$target = $event->getTarget();
$whiteList = array('Auth\\Controller\\Index-index', 'Auth\\Controller\\Index-logout');
$requestUri = $request->getRequestUri();
$controller = $event->getRouteMatch()->getParam('controller');
$action = $event->getRouteMatch()->getParam('action');
$requestedResourse = $controller . "-" . $action;
$session = new Container('User');
if ($session->offsetExists('email')) {
if ($requestedResourse == 'Auth\\Controller\\Index-index' || in_array($requestedResourse, $whiteList)) {
$url = '/';
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
$response->setStatusCode(302);
} else {
$serviceManager = $event->getApplication()->getServiceManager();
$userRole = $session->offsetGet('roleName');
$acl = $serviceManager->get('Acl');
$acl->initAcl();
$status = $acl->isAccessAllowed($userRole, $controller, $action);
if (!$status) {
die('Permission denied');
}
}
} else {
if ($requestedResourse != 'Auth\\Controller\\Index-index' && !in_array($requestedResourse, $whiteList)) {
$url = '/login';
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
$response->setStatusCode(302);
}
$response->sendHeaders();
}
}
示例14: boforeDispatch
function boforeDispatch(MvcEvent $event)
{
include 'config/constant.php';
$response = $event->getResponse();
$controller = $event->getRouteMatch()->getParam('controller');
$module_array = explode("\\", $controller);
if ($module_array[0] == 'Admin') {
$action = $event->getRouteMatch()->getParam('action');
$requestedResourse = $controller . "\\" . $action;
$session = new Container('User');
if ($session->offsetExists('user')) {
if (in_array($requestedResourse, $GLOBALS['PAGE_BEFORE_LOGIN'])) {
$url = $GLOBALS['SITE_ADMIN_URL'] . 'dashboard/add';
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
$response->setStatusCode(302);
}
} else {
if ($requestedResourse != 'Admin\\Controller\\Index\\index' && !in_array($requestedResourse, $GLOBALS['PAGE_BEFORE_LOGIN'])) {
$url = $GLOBALS['SITE_ADMIN_URL'] . 'index/login';
$response->setHeaders($response->getHeaders()->addHeaderLine('Location', $url));
$response->setStatusCode(302);
}
$response->sendHeaders();
}
}
}
示例15: testExchangeArrayObject
public function testExchangeArrayObject()
{
$this->container->offsetSet('old', 'old');
$this->assertTrue($this->container->offsetExists('old'));
$old = $this->container->exchangeArray(new \Zend\Stdlib\ArrayObject(array('new' => 'new')));
$this->assertArrayHasKey('old', $old, "'exchangeArray' doesn't return an array of old items");
$this->assertFalse($this->container->offsetExists('old'), "'exchangeArray' doesn't remove old items");
$this->assertTrue($this->container->offsetExists('new'), "'exchangeArray' doesn't add the new array items");
}