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


PHP GlobalAdapterFeature::setStaticAdapter方法代碼示例

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


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

示例1: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($e->getApplication()->getServiceManager()->get('Zend\\Db\\Adapter\\Adapter'));
     // running access check
     /*  $eventManager->attach(MvcEvent::EVENT_ROUTE,
        		function  ($e)
        		{
        			$login = $e->getRouter()->assemble(array(), array('name' => 'login'));
        			$match = $e->getRouteMatch();
        			$name = $match->getMatchedRouteName();
        			if ('profile' == $name){
        				$auth   = $e->getApplication()
        				->getServiceManager()
        				->get('Zend\Authentication\AuthenticationService');
        				if(false === $auth->hasIdentity())
        				{
        					$response = $e->getResponse();
        					$response->getHeaders()
        					->addHeaderLine('Location', $login);
        					$response->setStatusCode(302);
        					return $response;
        				}
        			}
        		}, - 100);
         */
 }
開發者ID:ntlzz93,項目名稱:Zend-Framework-2---IOT,代碼行數:29,代碼來源:Module.php

示例2: getServiceConfig

 /**
  * Get Service configuration
  */
 public function getServiceConfig()
 {
     return array('factories' => array('Model' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($dbAdapter);
         return \Emp\Model\Factory::getInstance();
     }));
 }
開發者ID:umangvarshney,項目名稱:zendtest,代碼行數:11,代碼來源:Module.php

示例3: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $adapter = $e->getApplication()->getServiceManager()->get('dbBatDongSan');
     GlobalAdapterFeature::setStaticAdapter($adapter);
 }
開發者ID:quangdungninh,項目名稱:zendvnteam,代碼行數:8,代碼來源:Module.php

示例4: prepareAdapter

 /**
  * Setup method -- make sure static adapter is available for testing.
  *
  * @return void
  */
 public static function prepareAdapter()
 {
     try {
         DbGlobalAdapter::getStaticAdapter();
     } catch (\Zend\Db\TableGateway\Exception\RuntimeException $e) {
         DbGlobalAdapter::setStaticAdapter(DbAdapterFactory::getAdapter());
     }
 }
開發者ID:no-reply,項目名稱:cbpl-vufind,代碼行數:13,代碼來源:DbTestCase.php

示例5: getServiceConfig

 public function getServiceConfig()
 {
     return array('factories' => array('Zend\\Db\\Adapter\\Adapter' => function ($serviceManager) {
         $adapterFactory = new \Zend\Db\Adapter\AdapterServiceFactory();
         $adapter = $adapterFactory->createService($serviceManager);
         \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($adapter);
         return $adapter;
     }));
 }
開發者ID:remithomas,項目名稱:rt-object,代碼行數:9,代碼來源:Module.php

示例6: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // set static adapter for all module table gateways
     $serviceManager = $e->getApplication()->getServiceManager();
     $dbAdapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
     \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($dbAdapter);
 }
開發者ID:vihang,項目名稱:nginad,代碼行數:11,代碼來源:Module.php

示例7: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     // You may not need to do this if you're doing it elsewhere in your
     // application
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $sm = $e->getApplication()->getServiceManager();
     $adapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($adapter);
 }
開發者ID:bbuehler99,項目名稱:cookingassist,代碼行數:11,代碼來源:Module.php

示例8: createService

 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @return \Home\Service\Store
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $adapterFactory = new \Zend\Db\Adapter\AdapterServiceFactory();
     $adapter = $adapterFactory->createService($serviceLocator);
     $config = $serviceLocator->get('Config');
     if (isset($config['db']['profilerEnabled']) && $config['db']['profilerEnabled']) {
         $adapter->setProfiler(new \Zend\Db\Adapter\Profiler\Profiler());
     }
     \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($adapter);
     return $adapter;
 }
開發者ID:NguyenQuiDuong,項目名稱:Funix,代碼行數:15,代碼來源:DbAdapterFactory.php

示例9: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     //inherit from znZend Module
     $sm = $e->getApplication()->getServiceManager();
     // Set global/static db adapter for feature-enabled TableGateways such as ZnZend\Model\AbstractMapper
     // For example only - up to application to set it as the service manager key for the db adapter may be different
     if ($sm->has('Zend\\Db\\Adapter\\Adapter')) {
         \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($sm->get('Zend\\Db\\Adapter\\Adapter'));
     }
 }
開發者ID:paengski13,項目名稱:MfCms,代碼行數:13,代碼來源:Module.php

示例10: testCreateServiceWithName

 public function testCreateServiceWithName()
 {
     $tableName = 'foo';
     $serviceLocatorMock = $this->getMock('Zend\\ServiceManager\\ServiceLocatorInterface');
     $moduleConfigMock = $this->getMockBuilder('T4webBase\\Module\\ModuleConfig')->disableOriginalConstructor()->getMock();
     $serviceLocatorMock->expects($this->at(0))->method('get')->with($this->equalTo('ModuleName\\ModuleConfig'))->will($this->returnValue($moduleConfigMock));
     $moduleConfigMock->expects($this->once())->method('getDbTableName')->with($this->equalTo('modulename-entity'))->will($this->returnValue($tableName));
     $dbAdapterMock = $this->getDbAdapterMock();
     GlobalAdapterFeature::setStaticAdapter($dbAdapterMock);
     $tableGateway = $this->abstractFactory->createServiceWithName($serviceLocatorMock, $name = 'foo', 'ModuleName\\Entity\\TableGateway');
     $this->assertInstanceOf('T4webBase\\Db\\TableGateway', $tableGateway);
     $this->assertAttributeSame($tableName, 'table', $tableGateway);
 }
開發者ID:t4web,項目名稱:base,代碼行數:13,代碼來源:TableGatewayAbstractFactoryTest.php

示例11: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $app = $e->getApplication();
     $sm = $app->getServiceManager();
     $request = $app->getRequest();
     $response = $app->getResponse();
     $appConfig = $sm->get('Configuration');
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($appConfig['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     $responseHeaders = $response->getHeaders();
     $requestHeaders = $request->getHeaders();
     $this->checkCloudFlareHttpHeader();
     $requestUriPath = $request->getUri()->getPath();
     $requestExtension = pathinfo($requestUriPath, PATHINFO_EXTENSION);
     if (!in_array($requestExtension, ['js', 'css'])) {
         $eventManager = $app->getEventManager();
         $moduleRouteListener = new ModuleRouteListener();
         $moduleRouteListener->attach($eventManager);
         $sharedManager = $eventManager->getSharedManager();
         $sharedManager->attach('Zend\\Mvc\\Controller\\AbstractActionController', 'dispatch', function ($e) use($sm) {
             $controller = $e->getTarget();
             $controller->getEventManager()->attachAggregate($sm->get('Visitor'));
         }, 2);
         $client = new RemoteAddress();
         $queryParams = $request->getQuery();
         $setPartnerId = (isset($queryParams['gid']) and is_numeric($queryParams['gid'])) ? ['gid' => (int) $queryParams['gid'], 'url' => $request->getUri()] : FALSE;
         $setLang = (isset($queryParams['lang']) and is_string($queryParams['lang'])) ? ['lang' => $queryParams['lang'], 'url' => $request->getUri()] : FALSE;
         $setCurrency = (isset($queryParams['cur']) and is_string($queryParams['cur'])) ? ['cur' => $queryParams['cur'], 'url' => $request->getUri()] : FALSE;
         if ($requestHeaders->has('Accept-Language')) {
             $browserLang = $requestHeaders->get('Accept-Language')->getPrioritized();
         } else {
             $browserLang = FALSE;
         }
         if ($requestHeaders->has('User-Agent')) {
             $userAgent = $requestHeaders->get('User-Agent')->getFieldValue();
         } else {
             $userAgent = FALSE;
         }
         if ($requestHeaders->has('Referer')) {
             $referer = $requestHeaders->get('Referer');
         } else {
             $referer = FALSE;
         }
         $eventManager->trigger('detectVisitor', $this, array('setLang' => $setLang, 'setCurrency' => $setCurrency, 'browserLang' => $browserLang, 'userAgent' => $userAgent, 'referer' => $referer, 'request' => $request, 'clientIp' => $client->getIpAddress(), 'clientProxy' => $client->getUseProxy(), 'setPartnerId' => $setPartnerId, 'sessionManager' => $sessionManager, 'response' => $response, 'responseHeaders' => $responseHeaders, 'requestHeaders' => $requestHeaders, 'serviceLocator' => $sm));
         $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_ROUTE, array($this, 'onPreDispatch'));
     }
     $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
     GlobalAdapterFeature::setStaticAdapter($dbAdapter);
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:51,代碼來源:Module.php

示例12: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     /**
      * @var Adapter $dbAdapter
      */
     $event = $e->getApplication();
     $eventManager = $event->getEventManager();
     $this->bootstrapSession($e);
     $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_ROUTE, [$this, 'onPreDispatch']);
     $eventManager->attach(\Zend\Mvc\MvcEvent::EVENT_ROUTE, [$this, 'onViewHelper']);
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // set static adapter for all module table gateways
     $serviceManager = $e->getApplication()->getServiceManager();
     $dbAdapter = $serviceManager->get('Zend\\Db\\Adapter\\Adapter');
     GlobalAdapterFeature::setStaticAdapter($dbAdapter);
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:17,代碼來源:Module.php

示例13: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $serviceManager = $e->getApplication()->getServiceManager();
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'setRouteMatch'), -1);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'setLanguages'), -2);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'accessControl'), -3);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'globalLayoutVars'), -4);
     $eventManager->attach(MvcEvent::EVENT_BOOTSTRAP, array($this, 'bootstrapSession'), 100);
     //use the error template of the currently used module
     $eventManager->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'controllerNotFound'), -200);
     $eventManager->attach(MvcEvent::EVENT_DISPATCH, array($this, 'actionNotFound'), -201);
     $eventManager->getSharedManager()->attach('custom', '403', function (MvcEvent $event) use($eventManager) {
         $viewModel = new ViewModel();
         $viewModel->setTemplate('error/403');
         $appViewModel = $event->getViewModel();
         $appViewModel->setTemplate('layout/layout');
         $appViewModel->addChild($viewModel, 'content');
         $eventManager->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $event) {
             $event->stopPropagation(true);
         }, 100);
     });
     $dbAdapter = $serviceManager->get('dbadapter');
     GlobalAdapterFeature::setStaticAdapter($dbAdapter);
     AbstractValidator::setDefaultTranslator(new \Zend\Mvc\I18n\Translator($serviceManager->get('translator')));
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $serviceManager->get('ViewHelperManager')->setFactory('langUrl', function () use($e) {
         $viewHelper = new View\Helper\Url($e->getRouteMatch());
         return $viewHelper;
     });
     if ($serviceManager->has('text-cache')) {
         // This will be used to check if there is already cached page and return it.
         // The priority must be low in order to be executed after the routing is done
         $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'getPageCache'), -1000);
         // And this will be used to save a generated cache page.
         // The priority must be low in order to be executed after the rendering is done
         $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'savePageCache'), -10000);
         $eventManager->attach(MvcEvent::EVENT_DISPATCH, array($this, 'getActionCache'), 2);
         $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'saveActionCache'), 0);
     }
 }
開發者ID:veniva,項目名稱:zcms,代碼行數:42,代碼來源:Module.php

示例14: onBootstrap

 public function onBootstrap(MvcEvent $event)
 {
     $services = $event->getApplication()->getServiceManager();
     $dbAdapter = $services->get('database');
     \Zend\Db\TableGateway\Feature\GlobalAdapterFeature::setStaticAdapter($dbAdapter);
     $eventManager = $event->getApplication()->getEventManager();
     $eventManager->attach(MvcEvent::EVENT_ROUTE, array($this, 'protectPage'), -100);
     $sharedEventManager = $event->getApplication()->getEventManager()->getSharedManager();
     $sharedEventManager->attach('user', 'log-fail', function ($event) use($services) {
         $username = $event->getParam('username');
         $log = $services->get('log');
         $log->warn('Error logging user [' . $username . ']');
     });
     $sharedEventManager->attach('user', 'register', function ($event) use($services) {
         $user = $event->getParam('user');
         $log = $services->get('log');
         $log->warn('Registered user [' . $user->getName() . '/' . $user->getId() . ']');
     });
     $eventManager->attach('render', array($this, 'injectUserAcl'));
 }
開發者ID:gioeleminardi,項目名稱:learnzf2,代碼行數:20,代碼來源:Module.php

示例15: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // initialize Global Static Db Adapter
     if ($e->getApplication()->getServiceManager()->has('Zend\\Db\\Adapter\\Adapter')) {
         $adapter = $e->getApplication()->getServiceManager()->get('Zend\\Db\\Adapter\\Adapter');
         GlobalAdapterFeature::setStaticAdapter($adapter);
     }
     // session
     $session = $e->getApplication()->getServiceManager()->get('Application\\SessionManager');
     $session->start();
     $container = new Container('initialized');
     if (!isset($container->init)) {
         $session->regenerateId(true);
         $container->init = 1;
     }
     Container::setDefaultManager($session);
     $this->bootstrapGlobalMvcEventErrorListener($e);
     $this->bootstrapSetLayouts($e);
 }
開發者ID:iprdp,項目名稱:sample-cart,代碼行數:22,代碼來源:Module.php


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