コード例 #1
0
 /**
  * Retrieve a resource from the container
  *
  * @param string $name
  * @return null|mixed
  */
 public function getResource($name)
 {
     // Make sure the resource is bootstraped
     if (!$this->hasResource($name)) {
         $this->bootstrap($name);
     }
     return parent::getResource($name);
 }
コード例 #2
0
ファイル: IndexController.php プロジェクト: bjtenao/tudu-web
 public function indexAction()
 {
     $error = $this->_request->getQuery('error');
     $redirect = $this->_request->getQuery('redirect');
     $lang = Tudu_Lang::getInstance()->load('login');
     $orgInfo = array();
     // 使用SSL登陆
     if ('http:' == PROTOCOL && strpos($this->options['sites']['www'], 'https:') === 0) {
         if (preg_replace('/^https:\\/\\//', '', $this->options['sites']['www']) == $this->_host) {
             $this->_redirect($this->options['sites']['www'] . $this->_request->getServer('REQUEST_URI'));
         } else {
             $this->_redirect('https://' . $this->_host . $this->_request->getServer('REQUEST_URI'));
         }
     }
     $memcache = $this->getInvokeArg('bootstrap')->getResource('memcache');
     $orgInfo = $memcache->get('TUDU-HOST-' . $this->_host);
     if (!empty($this->session->auth['appinvoker'])) {
         return;
     }
     if (!$orgInfo) {
         /* @var $daoOrg Dao_Md_Org_Org */
         $daoOrg = Oray_Dao::factory('Dao_Md_Org_Org', $this->bootstrap->getResource('multidb')->getDefaultDb());
         $orgInfo = $daoOrg->getOrgByHost($this->_host);
         $flag = null;
         $memcache->set('TUDU-HOST-' . $this->_host, $orgInfo, $flag, 3600);
     }
     if ($this->_user && $this->_user->isLogined() && $this->_user->orgId == $orgInfo->orgId) {
         return $this->_redirect(PROTOCOL . '//' . $this->_request->getServer('HTTP_HOST') . '/frame');
     }
     if ($orgInfo instanceof Dao_Md_Org_Record_Org) {
         $orgInfo = $orgInfo->toArray();
         if (!empty($this->options['tudu']['customdomain'])) {
             $this->options['sites']['tudu'] = PROTOCOL . '//' . $orgInfo['orgid'] . '.' . $this->options['tudu']['domain'];
         }
     }
     if (in_array($error, array('params', 'failure', 'locked', 'unsupport', 'timeout', 'notexist', 'seccode', 'forbid')) && array_key_exists($error, $lang)) {
         $this->view->error = $error;
     }
     if ($error == 'admin') {
         $this->view->fromadmin = true;
     }
     $this->view->org = $orgInfo;
     $this->view->lang = $lang;
     $this->view->redirect = $redirect;
     $this->view->options = array('sites' => $this->options['sites'], 'tudu' => $this->options['tudu']);
     // 选择登陆模板
     if (!empty($orgInfo) && !empty($orgInfo['loginskin'])) {
         $loginSkin = $orgInfo['loginskin'];
         if (!empty($loginSkin['selected']) && !empty($loginSkin['selected']['value']) && $loginSkin['selected']['value'] != 'SYS:default') {
             $this->view->loginskin = $orgInfo['loginskin'];
             $this->render('custom');
         }
     }
 }
コード例 #3
0
ファイル: BootstrapAbstractTest.php プロジェクト: netvlies/zf
 /**
  * @group ZF-6543
  */
 public function testPluginClassesDefiningExplicitTypeWillBeRegisteredWithThatValue()
 {
     $this->application->setOptions(array('resources' => array('Zend_Application_Bootstrap_BootstrapAbstractTest_Layout' => array(), 'layout' => array())));
     $bootstrap = new Zend_Application_Bootstrap_Bootstrap($this->application);
     $bootstrap->bootstrap('BootstrapAbstractTestLayout');
     $resource1 = $bootstrap->getResource('BootstrapAbstractTestLayout');
     $bootstrap->bootstrap('layout');
     $resource2 = $bootstrap->getResource('layout');
     $this->assertNotSame($resource1, $resource2);
     $this->assertTrue($resource1 instanceof Zend_Application_Bootstrap_BootstrapAbstractTest_Layout, var_export(array_keys($bootstrap->getPluginResources()), 1));
     $this->assertTrue($resource2 instanceof Zend_Layout);
 }
コード例 #4
0
 /**
  * Returns the requested resource and applies lazy
  * loading if necessary.
  *
  * @param string $name
  * @return mixed|null
  */
 public function getResource($name)
 {
     $result = parent::getResource($name);
     if ($this->isLazyLoader($result)) {
         // The resource uses lazy loading. As the resource
         // is requested now we have to load it finally.
         // The LazyLoader ensures that the resource is executed
         // only once, even if getResource() is called multiple
         // times.
         /* @var $result Mol_Application_Bootstrap_LazyLoader */
         return $result->load();
     }
     return $result;
 }