|
@@ -46,11 +46,11 @@ class Application
|
|
|
return $this->apps ?: ($this->apps = (array) config('admin.multi_app'));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置当前应用配置.
|
|
|
- *
|
|
|
- * @param string $app
|
|
|
- */
|
|
|
+ public function getEnabledApps()
|
|
|
+ {
|
|
|
+ return array_filter($this->getApps());
|
|
|
+ }
|
|
|
+
|
|
|
public function switch(string $app = null)
|
|
|
{
|
|
|
$this->withName($app);
|
|
@@ -58,29 +58,16 @@ class Application
|
|
|
$this->withConfig($this->name);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置应用名称.
|
|
|
- *
|
|
|
- * @param string $app
|
|
|
- */
|
|
|
public function withName(string $app)
|
|
|
{
|
|
|
$this->name = $app;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取当前应用名称.
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
public function getName()
|
|
|
{
|
|
|
return $this->name ?: static::DEFAULT;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 注册应用.
|
|
|
- */
|
|
|
public function boot()
|
|
|
{
|
|
|
$this->registerRoute(static::DEFAULT);
|
|
@@ -92,11 +79,6 @@ class Application
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 注册路由.
|
|
|
- *
|
|
|
- * @param string|\Closure $pathOrCallback
|
|
|
- */
|
|
|
public function routes($pathOrCallback)
|
|
|
{
|
|
|
$this->loadRoutesFrom($pathOrCallback, static::DEFAULT);
|
|
@@ -123,31 +105,16 @@ class Application
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return string
|
|
|
- */
|
|
|
public function getCurrentApiRoutePrefix()
|
|
|
{
|
|
|
return $this->getApiRoutePrefix($this->getName());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param string|null $app
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
public function getApiRoutePrefix(?string $app = null)
|
|
|
{
|
|
|
return $this->getRoutePrefix($app).'dcat-api.';
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取路由别名前缀.
|
|
|
- *
|
|
|
- * @param string|null $app
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
public function getRoutePrefix(?string $app = null)
|
|
|
{
|
|
|
$app = $app ?: $this->getName();
|
|
@@ -155,25 +122,11 @@ class Application
|
|
|
return 'dcat.'.$app.'.';
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 获取路由别名.
|
|
|
- *
|
|
|
- * @param string|null $route
|
|
|
- * @param array $params
|
|
|
- * @param bool $absolute
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
public function getRoute(?string $route, array $params = [], $absolute = true)
|
|
|
{
|
|
|
return route($this->getRoutePrefix().$route, $params, $absolute);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 注册应用路由.
|
|
|
- *
|
|
|
- * @param string|null $app
|
|
|
- */
|
|
|
protected function registerRoute(?string $app)
|
|
|
{
|
|
|
$this->switch($app);
|
|
@@ -187,11 +140,6 @@ class Application
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 设置应用配置.
|
|
|
- *
|
|
|
- * @param string $app
|
|
|
- */
|
|
|
protected function withConfig(string $app)
|
|
|
{
|
|
|
if (! isset($this->configs[$app])) {
|
|
@@ -201,14 +149,6 @@ class Application
|
|
|
config(['admin' => $this->configs[$app]]);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 加载路由文件.
|
|
|
- *
|
|
|
- * @param string $path
|
|
|
- * @param string $app
|
|
|
- *
|
|
|
- * @return void
|
|
|
- */
|
|
|
protected function loadRoutesFrom($path, ?string $app)
|
|
|
{
|
|
|
Route::group(array_filter([
|