本文整理汇总了PHP中Zend\Session\Container::offsetSet方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::offsetSet方法的具体用法?PHP Container::offsetSet怎么用?PHP Container::offsetSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Session\Container
的用法示例。
在下文中一共展示了Container::offsetSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: userAuthentication
protected function userAuthentication($data)
{
$auth = $this->authService;
$adapter = $auth->getAdapter();
$adapter->setIdentityValue($data['username']);
$adapter->setCredentialValue($data['password']);
$authResult = $auth->authenticate();
if ($authResult->isValid()) {
$identity = $authResult->getIdentity();
$auth->getStorage()->write($identity);
$sessionManager = new SessionManager();
if ($data['rememberme']) {
$sessionManager->rememberMe();
}
// store user roles in a session container
$userContainer = new Container('User');
$userContainer->offsetSet('id', $identity->getUserId());
$userRoles = $identity->getRole()->toArray();
$roleNames = array();
foreach ($userRoles as $userRole) {
$roleNames[] = $userRole->getRoleName();
}
$userContainer->offsetSet('activeRole', $roleNames[0]);
$userContainer->offsetSet('allRoles', $roleNames);
$sessionManager->writeClose();
return true;
}
return false;
}
示例3: 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;
}
}
示例4: csvAction
public function csvAction()
{
if ($this->getRequest()->isPost()) {
$request = $this->getRequest();
$post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$form = new ContenutiFormSearch();
$form->addSubmitButton();
$form->setBindOnValidate(false);
$form->setData($post);
if ($form->isValid()) {
$sessionContainer = new SessionContainer();
$sessionContainer->offsetSet('contenutiFormSearch', $post);
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$wrapper = new ContenutiGetterWrapper(new ContenutiGetter($em));
$wrapper->setInput(array('limit' => 1500));
$wrapper->setupQueryBuilder();
$records = $wrapper->getRecords();
$csvExportHelper = new CsvExportHelper();
if (!empty($records)) {
$arrayContent = array();
$arrayContent[] = array('Titolo', 'Sottotitolo', 'Testo');
foreach ($records as $record) {
$arrayContent[] = array($record['titolo'], $record['sommario'], $record['testo']);
}
$content = $csvExportHelper->makeCsvLine($arrayContent);
$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'text/csv')->addHeaderLine('Content-Disposition', 'attachment; filename="contenuti_' . date("dmYHis") . '.csv"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
$response->setContent($content);
return $response;
}
}
}
return $this->redirectForUnvalidAccess();
}
示例5: csvAction
/**
* CSV export
*
* @return \Zend\Http\Response|\Zend\Stdlib\ResponseInterface
* @throws \ModelModule\Model\NullException
*/
public function csvAction()
{
if ($this->getRequest()->isPost()) {
$request = $this->getRequest();
$post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$form = new StatoCivileFormSearch();
$form->setBindOnValidate(false);
$form->setData($post);
if ($form->isValid()) {
$sessionContainer = new SessionContainer();
$sessionContainer->offsetSet('statoCivileFormSearch', $post);
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$wrapper = new StatoCivileGetterWrapper(new StatoCivileGetter($em));
$wrapper->setInput(array('numero' => isset($post['numero']) ? $post['numero'] : null, 'anno' => isset($post['anno']) ? $post['anno'] : null, 'sezioneId' => isset($post['sezione']) ? $post['sezione'] : null, 'noScaduti' => isset($post['expired']) ? $post['expired'] : null, 'textSearch' => isset($post['testo']) ? $post['testo'] : null, 'orderBy' => 'sca.id DESC', 'limit' => 1500));
$wrapper->setupQueryBuilder();
$records = $wrapper->getRecords();
if (!empty($records)) {
$arrayContent = array();
$arrayContent[] = array('Titolo', 'Numero \\ Anno', 'Inserito il', 'Scadenza');
foreach ($records as $record) {
$arrayContent[] = array($record['titolo'], $record['progressivo'] . ' / ' . $record['anno'], $record['data']->format("d-m-Y"), $record['scadenza']->format("d-m-Y"));
}
$csvExportHelper = new CsvExportHelper();
$content = $csvExportHelper->makeCsvLine($arrayContent);
$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'text/csv')->addHeaderLine('Content-Disposition', 'attachment; filename="stato_civile_' . date("dmYHis") . '.csv"')->addHeaderLine('Accept-Ranges', 'bytes')->addHeaderLine('Content-Length', strlen($content));
$response->setContent($content);
return $response;
}
}
}
return $this->redirectForUnvalidAccess();
}
示例6: setReferer
public function setReferer($referer = "")
{
$sessionReferer = new Container('referer');
if (strlen($referer) > 0) {
$sessionReferer->offsetSet('referer', $referer);
}
}
示例7: indexAction
public function indexAction()
{
$request = $this->getRequest();
$view = new ViewModel();
$loginForm = new LoginForm('loginForm');
$loginForm->setInputFilter(new LoginFilter());
if ($request->isPost()) {
$data = $request->getPost();
$loginForm->setData($data);
if ($loginForm->isValid()) {
$data = $loginForm->getData();
$userPassword = new UserPassword();
$encyptPass = $userPassword->create($data['password']);
$this->getAuthService()->getAdapter()->setIdentity($data['email'])->setCredential($encyptPass);
$result = $this->getAuthService()->authenticate();
if ($result->isValid()) {
$session = new Container('User');
$session->offsetSet('email', $data['email']);
$this->flashMessenger()->addMessage(array('success' => 'Login Success.'));
// Redirect to page after successful login
} else {
$this->flashMessenger()->addMessage(array('error' => 'invalid credentials.'));
// Redirect to page after login failure
}
return $this->redirect()->tourl('/application/login');
// Logic for login authentication
} else {
$errors = $loginForm->getMessages();
//prx($errors);
}
}
$view->setVariable('loginForm', $loginForm);
return $view;
}
示例8: indexAction
/**
* Set search session
*
* @return \Zend\Http\Response
*/
public function indexAction()
{
if ($this->getRequest()->isPost()) {
$request = $this->getRequest();
$post = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$inputFilter = new PostsFormSearchInputFilter();
$formSearch = new PostsFormSearch();
$formSearch->setInputFilter($inputFilter->getInputFilter());
$formSearch->setData($post);
$currentClass = get_class($this);
$sessionIdentifier = $currentClass::sessionIdentifier;
if ($formSearch->isValid()) {
$inputFilter->exchangeArray($formSearch->getData());
$formSearch->setData($post);
$sessioContainer = new SessionContainer();
$sessioContainer->offsetSet($sessionIdentifier, array('testo' => $inputFilter->testo, 'categories' => $inputFilter->category));
$referer = $this->getRequest()->getHeader('Referer');
if (is_object($referer)) {
return $this->redirect()->toUrl($referer->getUri());
}
}
$mainLayout = $this->initializeFrontendWebsite();
$referer = $this->getRequest()->getHeader('Referer');
$this->layout()->setVariables(array('formMessages' => $formSearch->getMessages(), 'refererUrl' => is_object($referer) ? $referer->getUri() : null, 'moduleLabel' => "Posts", 'templatePartial' => 'form-message.phtml'));
$this->layout()->setTemplate($mainLayout);
} else {
$referer = $this->getRequest()->getHeader('Referer');
if (is_object($referer)) {
return $this->redirect()->toUrl($referer->getUri());
}
return $this->redirect()->toRoute('main');
}
}
示例9: indexAction
/**
* @return mixed
*/
public function indexAction()
{
if ($this->getRequest()->isPost()) {
$request = $this->getRequest();
$post = $request->getPost()->toArray();
$inputFilter = new SottoSezioniFormSearchInputFilter();
$formSearch = new SottoSezioniFormSearch();
$formSearch->setData($post);
if ($formSearch->isValid()) {
$inputFilter->exchangeArray($formSearch->getData());
$sessioContainer = new SessionContainer();
$sessioContainer->offsetSet(self::sessionIdentifier, array('testo' => $inputFilter->testo, 'sottosezioni' => $inputFilter->sezioni));
$referer = $this->getRequest()->getHeader('Referer');
if (is_object($referer)) {
return $this->redirect()->toUrl($referer->getUri());
}
}
$mainLayout = $this->initializeFrontendWebsite();
$moduleUrl = $this->url()->fromRoute('main', array('lang' => 'it'));
$referer = $this->getRequest()->getHeader('Referer');
$refererUrl = is_object($referer) ? $referer->getUri() : $moduleUrl;
$this->layout()->setVariables(array('formMessages' => $formSearch->getMessages(), 'refererUrl' => $refererUrl, 'moduleUrl' => $moduleUrl, 'moduleLabel' => "Contenuti", 'templatePartial' => 'form-message.phtml'));
$this->layout()->setTemplate($mainLayout);
} else {
$referer = $this->getRequest()->getHeader('Referer');
if (is_object($referer)) {
return $this->redirect()->toUrl($referer->getUri());
}
return $this->redirect()->toRoute('main');
}
}
示例10: setAuthenticationExpirationTime
public function setAuthenticationExpirationTime()
{
$expirationTime = time() + $this->allowedIdleTimeInSeconds;
$authSession = new Container(self::SESSION_CONTAINER_NAME);
if ($authSession->offsetExists(self::SESSION_VARIABLE_NAME)) {
$authSession->offsetUnset(self::SESSION_VARIABLE_NAME);
}
$authSession->offsetSet(self::SESSION_VARIABLE_NAME, $expirationTime);
}
示例11: 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");
}
示例12: getLoginUrl
/**
* @param string $returnUrl
*
* @return string
*/
public function getLoginUrl($returnUrl)
{
$config = array('consumerKey' => $this->consumerKey, 'consumerSecret' => $this->consumerSecret, 'callbackUrl' => $returnUrl, 'siteUrl' => 'https://api.twitter.com/oauth', 'authorizeUrl' => 'https://api.twitter.com/oauth/authenticate');
$httpClientOptions = array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false));
$consumer = new Consumer($config);
$consumer->setHttpClient($consumer->getHttpClient()->setOptions($httpClientOptions));
$token = $consumer->getRequestToken();
$tw_session = new Container('twitter');
$tw_session->offsetSet('request_token', serialize($token));
return $consumer->getRedirectUrl();
}
示例13: index05Action
public function index05Action()
{
$ssUser = new Container("user");
$ssGroup = new Container("group");
$ssUser->offsetSet("fullname", "trongle");
$ssGroup->offsetSet("groupname", "sasfsaf");
$ssUser->getManager()->getStorage()->clear("group");
echo $ssUser->offsetGet("fullname");
echo $ssGroup->offsetGet("groupname");
return false;
}
示例14: photosearchAction
public function photosearchAction()
{
// TODO: set session searcch for pictures
if ($this->getRequest()->isPost()) {
$formSearch = new PostsFormSearch();
// $formSearch->setData();
$session = new SessionContainer();
$session->offsetSet('photoSearchSession', array('text' => '', 'category' => ''));
}
return $this->redirect()->toRoute('main');
}
示例15: languageAction
public function languageAction()
{
$session = new Container('base');
// $session->offsetSet ( 'language', "es_ES" );
//$session->offsetSet ( 'language', "en_US" );
if ($this->getEvent()->getRouteMatch()->getParam('lang') != "") {
$session->offsetSet('language', $this->getEvent()->getRouteMatch()->getParam('lang'));
}
$result = new JsonModel(array('language' => $session->offsetGet('language'), 'success' => true));
return $result;
}