Beispiel #1
0
 public function getExportDir(string $version, int $deep = 0)
 {
     $dir = App::getApp()->path('export', $version . ($deep > 0 ? '_' . $deep : ''));
     if (!is_dir($dir)) {
         mkdir($dir, 0755, true);
         return $dir;
     }
     return $this->getExportDir($version, $deep + 1);
 }
Beispiel #2
0
 public function getRouter()
 {
     if (!isset($this->router)) {
         $this->router = new Router();
         if (!empty(self::$routes)) {
             $this->router->routes += self::$routes;
         }
         $this->router->loadFile($this->app->config('routes', 'php'));
     }
     return $this->router;
 }
Beispiel #3
0
 protected function onConstruct($argv = null)
 {
     $this->src = App::getApp()->src();
     $this->adapter = Db::getAdapter($this->source);
     $this->className = str_replace('/', '\\', $this->className);
     list($this->namespace, $this->className) = parse_class($this->className);
     if (empty($this->tableName)) {
         $this->tableName = strtolower($this->className);
     }
     $this->tableName = Db::mkTableName($this->source, $this->className, $this->tableName);
 }
Beispiel #4
0
 public final function __construct(Argv $argv = null)
 {
     // 绑定当前的默认的上下文环境实例
     if (!isset(self::$context)) {
         self::$context = $this;
     }
     $this->app = App::getApp();
     if (!$this->app->isInit()) {
         $this->app->init();
     }
     $this->app->getLoader()->loadHelper('string');
     $this->writer = new Writer();
     $this->cwd = real_path(getcwd());
     // 将错误和异常处理,从App中接管过来。
     register_shutdown_function(function () {
         $this->onExiting();
     });
     set_error_handler([$this, 'errorHandle']);
     set_exception_handler([$this, 'exceptionHandle']);
     if (isset($argv)) {
         $this->setArgv($argv);
     }
 }
Beispiel #5
0
 protected function onPrepareCache(string $key, array $args)
 {
     $file = App::getApp()->config($args[0], 'php');
     $this->loadCharSet($file);
 }
Beispiel #6
0
 public function getPath()
 {
     return App::getApp()->src("{$this->class}", 'php');
 }
Beispiel #7
0
 public function getDownloadPath(string $name, bool $isPreDir = false)
 {
     $library = $this->getLibrary($name);
     $app = App::getApp();
     if (empty($library['version'])) {
         $path = $app->web("vendor/{$name}", $library['type']);
     } else {
         $path = $app->web("vendor/{$name}-{$library['version']}", $library['type']);
     }
     if ($isPreDir) {
         $dir = dirname($path);
         if (!is_dir($dir)) {
             mkdir($dir, 0755, true);
         }
     }
     return $path;
 }
Beispiel #8
0
 public function getLogPath()
 {
     return App::getApp()->tmp('references_log.php');
 }
Beispiel #9
0
 public function getAppParentDir()
 {
     return dirname($this->thisApp->root());
 }