当前位置: 首页>>代码示例>>PHP>>正文


PHP G::get方法代码示例

本文整理汇总了PHP中G::get方法的典型用法代码示例。如果您正苦于以下问题:PHP G::get方法的具体用法?PHP G::get怎么用?PHP G::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在G的用法示例。


在下文中一共展示了G::get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct()
 {
     $defaultRoute = G::get('default_route');
     if ($defaultRoute != null) {
         $this->addRoute('_default', $this->_getRouteFromArray($defaultRoute));
     } else {
         $this->addRoute('_default', new Route_Static());
     }
 }
开发者ID:liu33851861,项目名称:CZD_Yaf_Extension,代码行数:9,代码来源:Router.php

示例2: throwException

 /**
  * Set the throwExceptions flag and retrieve current status
  *
  * Set whether exceptions encounted in the dispatch loop should be thrown
  * or caught and trapped in the response object.
  *
  * Default behaviour is to trap them in the response object; call this
  * method to have them thrown.
  *
  * Passing no value will return the current value of the flag; passing a
  * boolean true or false value will set the flag and return the current
  * object instance.
  *
  * @param boolean $flag Defaults to null (return flag state)
  * @return boolean|Yaf_Dispatcher Used as a setter,
  *     returns object; as a getter, returns boolean
  */
 public function throwException($flag = null)
 {
     if ($flag !== null) {
         G::set('throwException', (bool) $flag);
         return $this;
     }
     return G::get('throwException');
 }
开发者ID:zhangjingpu,项目名称:yaf-lib,代码行数:25,代码来源:Dispatcher.php

示例3: getViewScript

 /**
  * Construct view script path
  *
  * Used by render() and display to determine the path to the view script.
  *
  * @param  string $action Defaults to action registered in request object
  * @return string
  * @throws InvalidArgumentException with bad $action
  */
 protected function getViewScript($action = null)
 {
     $request = $this->getRequest();
     if (null === $action) {
         $action = $request->getActionName();
     } elseif (!is_string($action)) {
         throw new \InvalidArgumentException('Invalid action for view rendering');
     }
     $action = str_replace('_', DIRECTORY_SEPARATOR, strtolower($action));
     $script = $action . '.' . G::get('view_ext');
     $controller = $request->getControllerName();
     if ($controller != null) {
         $controller = str_replace('_', DIRECTORY_SEPARATOR, strtolower($controller));
     }
     $script = $controller . DIRECTORY_SEPARATOR . $script;
     return $script;
 }
开发者ID:zhangjingpu,项目名称:yaf-lib,代码行数:26,代码来源:Abstract.php

示例4: parseOptions

 /**
  * Parse application options
  *
  * @param  array $options
  * @throws Yaf_Exception When no bootstrap path is provided
  * @throws Yaf_Exception When invalid bootstrap information are provided
  * @return Yaf_Application
  */
 protected function parseOptions(array $options)
 {
     if (!is_array($options)) {
         throw new Exception\TypeError('Expected an array of application configure');
     }
     $options = array_change_key_case($options, CASE_LOWER);
     if (!isset($options['application'])) {
         throw new Exception\TypeError('Expected an array of application configure');
     }
     $options = $options['application'];
     if (!empty($options['directory'])) {
         G::set('directory', preg_replace("/" . preg_quote(DIRECTORY_SEPARATOR, "/") . "\$/", "", $options['directory']));
     } else {
         throw new Exception\StartupError('Expected a directory entry in application configures');
     }
     if (!empty($options['ext'])) {
         G::set('ext', $options['ext']);
     }
     if (!empty($options['bootstrap']) && is_string($options['bootstrap'])) {
         $this->_options['bootstrap'] = $options['bootstrap'];
     }
     if (!empty($options['library'])) {
         if (is_string($options['library'])) {
             $this->_options['local_library'] = $options['library'];
         } elseif (is_array($options['library'])) {
             if (!empty($options['library']['directory']) && is_string($options['library']['directory'])) {
                 $this->_options['local_library'] = $options['library']['directory'];
             }
             if (!empty($options['library']['namespace']) && is_string($options['library']['namespace'])) {
                 $this->_options['local_namespace'] = $options['library']['namespace'];
             }
         }
     } else {
         $this->_options['local_library'] = G::get('directory') . DIRECTORY_SEPARATOR . Loader::YAF_LIBRARY_DIRECTORY_NAME;
     }
     if (!empty($options['view']) && is_array($options['view']) && !empty($options['view']['ext']) && is_string($options['view']['ext'])) {
         G::set('view_ext', $options['view']['ext']);
     }
     if (!empty($options['baseUri']) && is_string($options['baseUri'])) {
         $this->_options['baseUri'] = $options['baseUri'];
     } else {
         $this->_options['baseUri'] = $_SERVER['PHP_SELF'];
     }
     if (!empty($options['dispatcher']) && is_array($options['dispatcher'])) {
         if (!empty($options['dispatcher']['defaultModule']) && is_string($options['dispatcher']['defaultModule'])) {
             G::set('default_module', $options['dispatcher']['defaultModule']);
         } else {
             G::set('default_module', Router::YAF_ROUTER_DEFAULT_MODULE);
         }
         if (!empty($options['dispatcher']['defaultController']) && is_string($options['dispatcher']['defaultController'])) {
             G::set('default_controller', $options['dispatcher']['defaultController']);
         } else {
             G::set('default_controller', Router::YAF_ROUTER_DEFAULT_CONTROLLER);
         }
         if (!empty($options['dispatcher']['defaultAction']) && is_string($options['dispatcher']['defaultAction'])) {
             G::set('default_action', $options['dispatcher']['defaultAction']);
         } else {
             G::set('default_action', Router::YAF_ROUTER_DEFAULT_ACTION);
         }
         if (isset($options['dispatcher']['throwException'])) {
             G::set('throwException', (bool) $options['dispatcher']['throwException']);
         }
         if (isset($options['dispatcher']['catchException'])) {
             G::set('catchException', (bool) $options['dispatcher']['catchException']);
         }
         if (isset($options['dispatcher']['defaultRoute']) && is_array($options['dispatcher']['defaultRoute'])) {
             G::set('default_route', $options['dispatcher']['defaultRoute']);
         }
     } else {
         G::set('default_module', Router::YAF_ROUTER_DEFAULT_MODULE);
         G::set('default_controller', Router::YAF_ROUTER_DEFAULT_CONTROLLER);
         G::set('default_action', Router::YAF_ROUTER_DEFAULT_ACTION);
         $this->_options['throwException'] = true;
         $this->_options['catchException'] = true;
     }
     if (!empty($options['modules']) && is_string($options['modules'])) {
         $modules = preg_split("/,/", $options['modules']);
         foreach ($modules as $module) {
             $this->_modules[] = trim($module);
         }
     }
     if (empty($this->_modules)) {
         $this->_modules[] = G::get('default_module');
     }
     return true;
 }
开发者ID:zhangjingpu,项目名称:yaf-lib,代码行数:94,代码来源:Application.php

示例5: resolveClass

 private function resolveClass($class)
 {
     // Autodiscover the path from the class name
     // Implementation is PHP namespace-aware, and based on
     // Framework Interop Group reference implementation:
     // http://groups.google.com/group/php-standards/web/psr-0-final-proposal
     $className = ltrim($class, '\\');
     $file = '';
     $namespace = '';
     if (($lastNsPos = strripos($className, '\\')) !== false) {
         $namespace = substr($className, 0, $lastNsPos);
         $className = substr($className, $lastNsPos + 1);
         $file = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
     }
     if (G::iniGet('yaf.lowcase_path') == true) {
         $file = strtolower($file);
         $segments = explode('_', $className);
         foreach ($segments as $key => &$value) {
             if ($key != count($segments) - 1) {
                 $value = strtolower($value);
             }
         }
         $file .= implode(DIRECTORY_SEPARATOR, $segments) . '.' . G::get('ext');
     } else {
         $file .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.' . G::get('ext');
     }
     return $file;
 }
开发者ID:liu33851861,项目名称:CZD_Yaf_Extension,代码行数:28,代码来源:Loader.php

示例6: getController

 private function getController($appDir, $module, $controller)
 {
     $controllerDir = '';
     if ($this->_default_module == $module) {
         $controllerDir = $appDir . DIRECTORY_SEPARATOR . Loader::YAF_CONTROLLER_DIRECTORY_NAME;
     } else {
         $controllerDir = $appDir . DIRECTORY_SEPARATOR . Loader::YAF_MODULE_DIRECTORY_NAME . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . Loader::YAF_CONTROLLER_DIRECTORY_NAME;
     }
     $nameSeparator = G::iniGet('yaf.name_separator');
     if (G::iniGet('yaf.name_suffix') == true) {
         $classname = $controller . $nameSeparator . 'Controller';
     } else {
         $classname = 'Controller' . $nameSeparator . $controller;
     }
     if (!@class_exists($classname, false)) {
         if (!Loader::getInstance()->internal_autoload($controller, $controllerDir)) {
             throw new Exception\LoadFailed\Controller('Could not find controller script ' . $controllerDir . DIRECTORY_SEPARATOR . $controller . '.' . G::get('ext'));
         }
     }
     if (!class_exists($classname, false)) {
         throw new Exception\LoadFailed\LoadFailed('Could not find class ' . $classname . ' in controller script ' . $controllerDir);
     }
     return $classname;
 }
开发者ID:liu33851861,项目名称:CZD_Yaf_Extension,代码行数:24,代码来源:Dispatcher.php


注:本文中的G::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。