Cml\Cml::getContainer PHP Method

getContainer() public static method

获得容器
public static getContainer ( ) : Container
return Container
    public static function getContainer()
    {
        if (is_null(self::$container)) {
            self::$container = new Container();
        }
        return self::$container;
    }

Usage Example

Esempio n. 1
0
 /**
  * 初始化目录
  *
  * @param string $templateFile 模板文件名
  *
  * @return string
  */
 private function initBaseDir($templateFile)
 {
     $baseDir = Cml::getContainer()->make('cml_route')->getAppName();
     $baseDir .= '/' . Cml::getApplicationDir('app_view_path_name') . (Config::get('html_theme') != '' ? DIRECTORY_SEPARATOR . Config::get('html_theme') : '');
     $layOutRootDir = $baseDir;
     if ($templateFile === '') {
         $baseDir .= '/' . Cml::getContainer()->make('cml_route')->getControllerName() . '/';
         $file = Cml::getContainer()->make('cml_route')->getActionName();
     } else {
         $templateFile = str_replace('.', '/', $templateFile);
         $baseDir .= DIRECTORY_SEPARATOR . dirname($templateFile) . DIRECTORY_SEPARATOR;
         $file = basename($templateFile);
     }
     return ['layoutDir' => Cml::getApplicationDir('apps_path') . DIRECTORY_SEPARATOR . $layOutRootDir, 'layoutCacheRootPath' => Cml::getApplicationDir('runtime_cache_path') . DIRECTORY_SEPARATOR . $layOutRootDir . DIRECTORY_SEPARATOR, 'templateDir' => Cml::getApplicationDir('apps_path') . DIRECTORY_SEPARATOR . $baseDir, 'cacheDir' => Cml::getApplicationDir('runtime_cache_path') . DIRECTORY_SEPARATOR . $baseDir, 'file' => $file];
 }
All Usage Examples Of Cml\Cml::getContainer