Skip to content

Commit

Permalink
修复:自动创建应用
Browse files Browse the repository at this point in the history
  • Loading branch information
dxkite committed Jul 7, 2019
1 parent 19e5028 commit b45126c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion suda/loader/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
defined('SUDA_DEBUG') or define('SUDA_DEBUG', false);
defined('SUDA_DEBUG_LEVEL') or define('SUDA_DEBUG_LEVEL', 'debug');
// 定义版本
define('SUDA_VERSION', '3.1.3-alpha');
define('SUDA_VERSION', '3.1.2');
// 设置默认时区
date_default_timezone_set(SUDA_TIMEZONE);
// 调试模式
Expand Down
20 changes: 11 additions & 9 deletions suda/src/application/builder/ApplicationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class ApplicationBuilder
* 创建应用
* @param Loader $loader
* @param string $path
* @param string $manifast
* @param string $manifest
* @param string $dataPath
* @return Application
*/
public static function build(Loader $loader, string $path, string $manifast, string $dataPath):Application
public static function build(Loader $loader, string $path, string $manifest, string $dataPath):Application
{
$manifestConfig = static::loadManifest($manifast);
$manifestConfig = static::loadManifest($path, $manifest);
if (array_key_exists('import', $manifestConfig)) {
static::importClassLoader($loader, $manifestConfig['import'], $path);
}
Expand All @@ -40,30 +40,32 @@ public static function build(Loader $loader, string $path, string $manifast, str
/**
* 加载App主配置
* @param string $path
* @param string $manifest
* @return array|null
*/
public static function loadManifest(string $path)
public static function loadManifest(string $path, string $manifest)
{
$manifest = static::resolveManifest($path);
$manifest = static::resolveManifest($path, $manifest);
return Config::loadConfig($manifest) ?? [];
}

/**
* 获取Manifest路径
*
* @param string $path
* @param string $manifestPath
* @return string
*/
protected static function resolveManifest(string $path):string
protected static function resolveManifest(string $path, string $manifestPath):string
{
$manifest = PathResolver::resolve($path);
$manifest = PathResolver::resolve($manifestPath);
if ($manifest === null) {
FileSystem::copyDir(SUDA_RESOURCE.'/app', $path);
$manifest = PathResolver::resolve($path);
$manifest = PathResolver::resolve($manifestPath);
}
if ($manifest === null) {
throw new ApplicationException(
sprintf('missing manifest in %s', dirname($path)),
sprintf('missing manifest in %s', dirname($manifestPath)),
ApplicationException::ERR_MANIFEST_IS_EMPTY
);
} else {
Expand Down

0 comments on commit b45126c

Please sign in to comment.