Skip to content

Commit

Permalink
调整
Browse files Browse the repository at this point in the history
  • Loading branch information
liu21st committed Mar 21, 2023
1 parent 6bec321 commit 64f5624
Showing 1 changed file with 6 additions and 36 deletions.
42 changes: 6 additions & 36 deletions src/MultiApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,9 @@ class MultiApp
/** @var App */
protected $app;

/**
* 应用名称
* @var string
*/
protected $name;

/**
* 应用名称
* @var string
*/
protected $appName;

/**
* 应用路径
* @var string
*/
protected $path;

public function __construct(App $app)
{
$this->app = $app;
$this->name = $this->app->http->getName();
$this->path = $this->app->http->getPath();
}

/**
Expand Down Expand Up @@ -90,15 +70,15 @@ protected function parseMultiApp(): bool
{
$scriptName = $this->getScriptName();
$defaultApp = $this->app->config->get('app.default_app') ?: 'index';
$appName = $this->app->http->getName();

if ($this->name || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) {
$appName = $this->name ?: $scriptName;
if ($appName || ($scriptName && !in_array($scriptName, ['index', 'router', 'think']))) {
$appName = $appName ?: $scriptName;
$this->app->http->setBind();
} else {
// 自动多应用识别
$this->app->http->setBind(false);
$appName = null;
$this->appName = '';
$appName = null;

$bind = $this->app->config->get('app.domain_bind', []);

Expand Down Expand Up @@ -142,7 +122,7 @@ protected function parseMultiApp(): bool
$appName = $map['*'];
} else {
$appName = $name ?: $defaultApp;
$appPath = $this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;
$appPath = $this->app->http->getPath() ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;

if (!is_dir($appPath)) {
$express = $this->app->config->get('app.app_express', false);
Expand Down Expand Up @@ -189,10 +169,9 @@ protected function getScriptName(): string
*/
protected function setApp(string $appName): void
{
$this->appName = $appName;
$this->app->http->name($appName);

$appPath = $this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;
$appPath = $this->app->http->getPath() ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR;

$this->app->setAppPath($appPath);
// 设置应用命名空间
Expand All @@ -207,15 +186,6 @@ protected function setApp(string $appName): void
}
}

/**
* 设置应用目录
* @param string $appPath
*/
public function setAppPath(string $appPath): void
{
$this->path = $appPath;
}

/**
* 加载应用文件
* @param string $appName 应用名
Expand Down

0 comments on commit 64f5624

Please # to comment.