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


PHP Container::setDefaultManager方法代碼示例

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


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

示例1: setSessionStorage

 public function setSessionStorage()
 {
     $options = new DbTableGatewayOptions();
     $options->setDataColumn('session_data')->setIdColumn('session_id')->setLifetimeColumn('life_time')->setModifiedColumn('update_time')->setNameColumn('session_name');
     $handler = new DbTableGateway($this->tblgw, $options);
     $this->sessionManager = new SessionManager();
     $this->sessionManager->setSaveHandler($handler);
     if ($this->sessionConfig) {
         $options = gv('options', $this->sessionConfig);
         $sessionConfig = new \Zend\Session\Config\SessionConfig();
         $sessionConfig->setOptions($options);
         $this->sessionManager->setConfig($sessionConfig);
     }
     $this->sessionManager->setSaveHandler($handler);
     Container::setDefaultManager($this->sessionManager);
     $this->sessionManager->start();
     $this->container = new Container('init');
     if (!$this->container->init) {
         $request = $this->request;
         $this->container->init = 1;
         $this->container->remoteAddr = $request->getServer()->get('REMOTE_ADDR');
         $this->container->httpUserAgent = $request->getServer()->get('HTTP_USER_AGENT');
         $this->container->create = time();
     }
     // update session id
     if (SESSION_ID_EXPIRE < time() - $this->container->create) {
         $this->sessionManager->regenerateId(true);
         $this->container->create = time();
     }
     return $this->sessionManager;
 }
開發者ID:jonathan1212,項目名稱:zf2,代碼行數:31,代碼來源:DbSessionStorage.php

示例2: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // Listeners to ensure that we always send back JSON.
     // If we set a 404 in the ViewModel, then the RouteNotFoundStrategy will add it's own
     // fields to the ViewModel, so detect a 404 first and respond to it
     $eventManager->getSharedManager()->attach('Zend\\Stdlib\\DispatchableInterface', MvcEvent::EVENT_DISPATCH, array($this, 'detect404'), -89);
     // Ensure we always render JSON
     $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'ensureJsonModel'), 999);
     // Turn errors into JSON
     // $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'renderError'));
     //*********Session
     $sm = $e->getApplication()->getServiceManager();
     $config = $sm->get('session_config');
     $storage = null;
     if ($sm->has('session_storage', false)) {
         $storage = $sm->get('session_storage');
     }
     $saveHandler = null;
     if ($sm->has('session_save_handler', false)) {
         $saveHandler = $sm->get('session_save_handler');
     }
     $sessionManager = new SessionManager($config, $storage, $saveHandler);
     Container::setDefaultManager($sessionManager);
     //$sessionManager->start();
 }
開發者ID:ledsinclouds,項目名稱:RestServerDemo,代碼行數:28,代碼來源:Module.php

示例3: onBootstrap

 public function onBootstrap(EventInterface $e)
 {
     /** @var \Zend\Mvc\Application $app */
     $app = $e->getTarget();
     $config = $app->getConfig();
     $sessionConfig = new SessionConfig();
     if (isset($config['session']['options'])) {
         $options = $config['session']['options'];
         if (isset($options['cookie_domain']) && strpos($_SERVER['SERVER_NAME'], $options['cookie_domain']) === false) {
             $options['cookie_domain'] = $_SERVER['SERVER_NAME'];
         }
         $sessionConfig->setOptions($options);
     }
     $serviceManager = $app->getServiceManager();
     $storage = null;
     $saveHandler = null;
     if ($serviceManager->has('Session\\Service\\Storage', false)) {
         /** @var \Zend\Session\Storage\StorageInterface $storage */
         $storage = $serviceManager->get('Session\\Service\\Storage');
     }
     if ($serviceManager->has('Session\\Service\\SaveHandler', false)) {
         /** @var \Zend\Session\SaveHandler\SaveHandlerInterface $saveHandler */
         $saveHandler = $serviceManager->get('Session\\Service\\SaveHandler');
     }
     Container::setDefaultManager(new SessionManager($sessionConfig, $storage, $saveHandler));
 }
開發者ID:hoangpt,項目名稱:nextcms,代碼行數:26,代碼來源:Module.php

示例4: testCanSetDefaultManagerToNull

 public function testCanSetDefaultManagerToNull()
 {
     $manager = new TestAsset\TestManager();
     Container::setDefaultManager($manager);
     Container::setDefaultManager(null);
     $this->assertNotSame($manager, Container::getDefaultManager());
 }
開發者ID:bradley-holt,項目名稱:zf2,代碼行數:7,代碼來源:ContainerTest.php

示例5: createService

 /**
  * @param ServiceLocatorInterface $sm
  * @return SessionManager
  */
 public function createService(ServiceLocatorInterface $sm)
 {
     $config = $sm->get('config');
     if (isset($config['session'])) {
         $session = $config['session'];
         $sessionConfig = null;
         if (isset($session['config'])) {
             $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
             $options = isset($session['config']['options']) ? $session['config']['options'] : array();
             $sessionConfig = new $class();
             $sessionConfig->setOptions($options);
         }
         $sessionStorage = null;
         if (isset($session['storage'])) {
             $class = $session['storage'];
             $sessionStorage = new $class();
         }
         $sessionSaveHandler = null;
         if (isset($session['save_handler'])) {
             $sessionSaveHandler = $sm->get($session['save_handler']);
         }
         $sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
     } else {
         $sessionManager = new SessionManager();
     }
     Container::setDefaultManager($sessionManager);
     return $sessionManager;
 }
開發者ID:RRcom,項目名稱:ZendSession,代碼行數:32,代碼來源:SessionManagerServiceFactory.php

示例6: getServiceConfig

 public function getServiceConfig()
 {
     return array('abstract_factories' => array('Zend\\Cache\\Service\\StorageCacheAbstractServiceFactory', 'Zend\\Log\\LoggerAbstractServiceFactory'), 'factories' => array('translator' => 'Zend\\Mvc\\Service\\TranslatorServiceFactory', 'Application\\SessionManager' => function ($sm) {
         $config = $sm->get('Config');
         if (isset($config['session'])) {
             $session = $config['session'];
             $sessionConfig = null;
             if (isset($session)) {
                 $sessionConfig = new \Zend\Session\Config\SessionConfig();
                 $sessionConfig->setOptions($session);
             }
             $storagePath = '';
             if (isset($config['app_base_dir'])) {
                 $storagePath = $config['app_base_dir'] . DIRECTORY_SEPARATOR;
             }
             $storagePath .= '/data/sessions/cache';
             $fileCacheStorage = new \Zend\Cache\Storage\Adapter\FileSystem(['cache_dir' => $storagePath]);
             $sessionSaveHandler = new \Zend\Session\SaveHandler\Cache($fileCacheStorage);
             $sessionManager = new \Zend\Session\SessionManager($sessionConfig, null, $sessionSaveHandler);
             if (isset($session['validators'])) {
                 $chain = $sessionManager->getValidatorChain();
                 foreach ($session['validators'] as $validator) {
                     $validator = new $validator();
                     $chain->attach('session.validate', array($validator, 'isValid'));
                 }
             }
         } else {
             $sessionManager = new \Zend\Session\SessionManager();
         }
         \Zend\Session\Container::setDefaultManager($sessionManager);
         return $sessionManager;
     }));
 }
開發者ID:iprdp,項目名稱:sample-cart,代碼行數:33,代碼來源:Module.php

示例7: __invoke

 public function __invoke(ContainerInterface $container)
 {
     $manager = new SessionManager();
     Container::setDefaultManager($manager);
     $realSessionContainer = new Container('zend_expressive');
     return new SessionContainer($realSessionContainer);
 }
開發者ID:dragonmantank,項目名稱:zendexpressive-session-middleware,代碼行數:7,代碼來源:ZendSessionFactory.php

示例8: createService

 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $sm)
 {
     $config = $sm->get('config');
     if (isset($config['session'])) {
         $session = $config['session'];
         $sessionConfig = null;
         if (isset($session['config'])) {
             $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
             $options = isset($session['config']['options']) ? $session['config']['options'] : array();
             $sessionConfig = new $class();
             $sessionConfig->setOptions($options);
         }
         $sessionStorage = null;
         if (isset($session['storage'])) {
             $class = $session['storage'];
             $sessionStorage = new $class();
         }
         $sessionSaveHandler = null;
         if (isset($session['save_handler'])) {
             // class should be fetched from service manager since it will require constructor arguments
             $sessionSaveHandler = $sm->get($session['save_handler']);
         }
         $sessionManager = new self($sessionConfig, $sessionStorage, $sessionSaveHandler);
     } else {
         $sessionManager = new self();
     }
     \Zend\Session\Container::setDefaultManager($sessionManager);
     return $sessionManager;
 }
開發者ID:daemonalchemist,項目名稱:atp-core,代碼行數:29,代碼來源:SessionManager.php

示例9: initSession

 public function initSession($config)
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
開發者ID:DCONLINE1984,項目名稱:surveyengine,代碼行數:8,代碼來源:Module.php

示例10: sessionStart

 public function sessionStart(MvcEvent $event)
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions(array());
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
開發者ID:petresevic,項目名稱:test,代碼行數:8,代碼來源:Module.php

示例11: bootstrapSession

 public function bootstrapSession($e)
 {
     $sessionManager = $e->getApplication()->getServiceManager()->get('Zend\\Session\\SessionManager');
     // TODO start session if session cookie exists?
     //$session->start();
     // ensure this session manager is used by default
     Container::setDefaultManager($sessionManager);
 }
開發者ID:zealproject,項目名稱:zeal-session,代碼行數:8,代碼來源:Module.php

示例12: tearDown

 public function tearDown()
 {
     $ref = new \ReflectionClass('Zend\\Validator\\Csrf');
     $hashCache = $ref->getProperty('hashCache');
     $hashCache->setAccessible(true);
     $hashCache->setValue(new Csrf(), array());
     SessionContainer::setDefaultManager(null);
 }
開發者ID:pnaq57,項目名稱:zf2demo,代碼行數:8,代碼來源:FormElementManagerFactoryTest.php

示例13: __invoke

 public function __invoke(ContainerInterface $container)
 {
     /** @var SessionManager $manager */
     $manager = $container->get(SessionManager::class);
     SessionContainer::setDefaultManager($manager);
     $manager->start();
     return new SessionMiddleware();
 }
開發者ID:mobicms,項目名稱:expressive-session,代碼行數:8,代碼來源:SessionMiddlewareFactory.php

示例14: init

 /**
  *  @return void
  */
 private function init()
 {
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($this->config);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     Container::setDefaultManager($sessionManager);
 }
開發者ID:kayo-almeida,項目名稱:cms-zend,代碼行數:11,代碼來源:Login.php

示例15: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('JYLibrary\\Model\\SessionTable' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $table = new SessionTable($dbAdapter);
         return $table;
     }, 'Zend\\Session\\SessionManager' => function ($sm) {
         $config = $sm->get('config');
         if (isset($config['session'])) {
             $session = $config['session'];
             $sessionConfig = null;
             if (isset($session['config'])) {
                 $class = isset($session['config']['class']) ? $session['config']['class'] : 'Zend\\Session\\Config\\SessionConfig';
                 $options = isset($session['config']['options']) ? $session['config']['options'] : array();
                 $sessionConfig = new $class();
                 $sessionConfig->setOptions($options);
             }
             $sessionStorage = null;
             if (isset($session['storage'])) {
                 $class = $session['storage'];
                 $sessionStorage = new $class();
             }
             $sessionSaveHandler = null;
             if (isset($session['save_handler'])) {
                 // class should be fetched from service manager since it will require constructor arguments
                 $sessionSaveHandler = $sm->get($session['save_handler']);
             }
             $sessionManager = new SessionManager($sessionConfig, $sessionStorage, $sessionSaveHandler);
             if (isset($session['validator'])) {
                 $chain = $sessionManager->getValidatorChain();
                 foreach ($session['validator'] as $validator) {
                     $validator = new $validator();
                     $chain->attach('session.validate', array($validator, 'isValid'));
                 }
             }
         } else {
             $sessionManager = new SessionManager();
             /*
             $adapter = new \Zend\Db\Adapter\Adapter(array(
             	'driver' => 'Mysqli',
             	'database' => 'jymobile',
             	'username' => 'root',
             	'password' => '',
             	'hostname'=>'localhost'
             ));
             
             $tableGateway = new TableGateway('session', $adapter);
             $saveHandler = new DbTableGateway($tableGateway, new DbTableGatewayOptions());
             $manager = new SessionManager();
             $manager->setSaveHandler($saveHandler);
             
             //echo '×Ô¶¨ÒåsessionManager';
             */
         }
         Container::setDefaultManager($sessionManager);
         return $sessionManager;
     }));
 }
開發者ID:blackjackedu,項目名稱:FreeMLib,代碼行數:58,代碼來源:Module.php


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