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); }
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); }
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); } }
protected function onPrepare($argv = null) { $this->thisApp = App::getApp(); $root = $this->getNewAppDir(); if (is_dir($root)) { throw new \Exception("Directory {$root} is existing!"); } $kephpEntry = relative_path($root, $this->thisApp->kephp()); list($path, $phar) = split_phar($kephpEntry); if ($phar !== false) { $kephpEntry = "'phar://' . __DIR__ . '{$path}/{$phar}{$this->entryFile}'"; } else { $kephpEntry = "__DIR__ . '{$path}{$this->entryFile}'"; } $this->context['kephpLibEntry'] = $kephpEntry; if (empty($this->appNamespace)) { $this->appNamespace = path2class($this->name); } else { if (!preg_match('#^[a-z0-9_]+$#i', $this->appNamespace)) { throw new \Exception("App namespace only can use char in a-z0-9_."); } } $this->context['appNamespace'] = trim($this->appNamespace, KE_PATH_NOISE); }
protected function onPrepareCache(string $key, array $args) { $file = App::getApp()->config($args[0], 'php'); $this->loadCharSet($file); }
public function getPath() { return App::getApp()->src("{$this->class}", 'php'); }
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; }
public final function __construct(Http $http = null) { // 绑定当前的默认的上下文环境实例 if (!isset(self::$web)) { self::$web = $this; } $this->app = App::getApp(); if (!$this->app->isInit()) { $this->app->init(); } $this->ob = OutputBuffer::getInstance()->start('webStart'); $this->mime = $this->app->getMime(); $this->http = $http ?? Http::current(); $this->component = (new Component())->setDirs(['appView' => [$this->app->appNs('View'), 100, Component::VIEW], 'appComponent' => [$this->app->appNs('Component'), 100], 'kephpComponent' => [$this->app->kephp('Ke/Component'), 1000]]); $this->prepare(); $this->onConstruct(); }
public function getLogPath() { return App::getApp()->tmp('references_log.php'); }