Cml\Config::load PHP Method

load() public static method

从文件载入Config
public static load ( string $file, boolean $global = true ) : array
$file string
$global boolean 是否从全局加载
return array
    public static function load($file, $global = true)
    {
        if (isset(static::$_content[$file])) {
            return static::$_content[$file];
        } else {
            $file = ($global ? Cml::getApplicationDir('global_config_path') : Cml::getApplicationDir('apps_path') . '/' . Cml::getContainer()->make('cml_route')->getAppName() . '/' . Cml::getApplicationDir('app_config_path_name')) . '/' . ($global ? self::$isLocal . DIRECTORY_SEPARATOR : '') . $file . '.php';
            if (!is_file($file)) {
                throw new ConfigNotFoundException(Lang::get('_NOT_FOUND_', $file));
            }
            static::$_content[$file] = Cml::requireFile($file);
            return static::$_content[$file];
        }
    }

Usage Example

Exemplo n.º 1
0
 /**
  * 从注释解析生成文档
  *
  */
 public static function parse()
 {
     $result = [];
     $config = Config::load('api', Cml::getApplicationDir('app_controller_path') ? true : false);
     foreach ($config['version'] as $version => $apiList) {
         isset($result[$version]) || ($result[$version] = []);
         foreach ($apiList as $model => $api) {
             $pos = strrpos($api, '\\');
             $controller = substr($api, 0, $pos);
             $action = substr($api, $pos + 1);
             if (class_exists($controller) === false) {
                 continue;
             }
             $annotationParams = self::getAnnotationParams($controller, $action);
             empty($annotationParams) || ($result[$version][$model] = $annotationParams);
         }
     }
     foreach ($result as $key => $val) {
         if (count($val) < 1) {
             unset($result[$key]);
         }
     }
     $systemCode = Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
     Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html', ['config' => $config, 'result' => $result, 'systemCode' => $systemCode]);
 }
All Usage Examples Of Cml\Config::load