Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0 fix multi app #366

Open
wants to merge 2 commits into
base: 3.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,39 @@ class Http extends \think\Http
{
use ModifyProperty;

/** @var Middleware */
/** @var Middleware[] */
protected static $middleware;

/** @var Route */
/** @var Route[] */
protected static $route;

protected function loadMiddleware(): void
{
if (!isset(self::$middleware)) {
if (!isset(self::$middleware[$this->app->http->name])) {
parent::loadMiddleware();
self::$middleware = clone $this->app->middleware;
$this->modifyProperty(self::$middleware, null);
self::$middleware[$this->app->http->name] = clone $this->app->middleware;
$this->modifyProperty(self::$middleware[$this->app->http->name], null);
}

$middleware = clone self::$middleware;
$middleware = clone self::$middleware[$this->app->http->name];
$this->modifyProperty($middleware, $this->app);
$this->app->instance("middleware", $middleware);
}

protected function loadRoutes(): void
{
if (!isset(self::$route)) {
if (!isset(self::$route[$this->app->http->name])) {
parent::loadRoutes();
self::$route = clone $this->app->route;
$this->modifyProperty(self::$route, null);
$this->modifyProperty(self::$route, null, 'request');
self::$route[$this->app->http->name] = clone $this->app->route;
$this->modifyProperty(self::$route[$this->app->http->name], null);
$this->modifyProperty(self::$route[$this->app->http->name], null, 'request');
}
}

protected function dispatchToRoute($request)
{
if (isset(self::$route)) {
$newRoute = clone self::$route;
if (isset(self::$route[$this->app->http->name])) {
$newRoute = clone self::$route[$this->app->http->name];
$this->modifyProperty($newRoute, $this->app);
$this->app->instance("route", $newRoute);
}
Expand Down