1
0
mirror of https://github.com/flarum/core.git synced 2025-10-18 10:16:09 +02:00

Get rid of Server classes for Admin, API and Forum

The various middleware can be registered in the service provider,
and the rest of the logic can all go through one single front
controller (index.php in flarum/flarum, and Flarum\Http\Server in
flarum/core).

This will also simplify the necessary server setup, as only one
rewrite rule remains.
This commit is contained in:
Franz Liedke
2017-06-30 12:07:20 +02:00
parent b4c7f8ca89
commit 69b517ea79
10 changed files with 263 additions and 318 deletions

View File

@@ -11,10 +11,6 @@
namespace Flarum\Event;
use Flarum\Admin\Server as AdminServer;
use Flarum\Api\Server as ApiServer;
use Flarum\Forum\Server as ForumServer;
use Flarum\Foundation\AbstractServer;
use Zend\Stratigility\MiddlewarePipe;
class ConfigureMiddleware
@@ -27,42 +23,35 @@ class ConfigureMiddleware
/**
* @var string
*/
public $path;
/**
* @var AbstractServer
*/
public $server;
public $stackName;
/**
* @param MiddlewarePipe $pipe
* @param string $path
* @param AbstractServer $server
* @param string $stackName
*/
public function __construct(MiddlewarePipe $pipe, $path, AbstractServer $server)
public function __construct(MiddlewarePipe $pipe, $stackName)
{
$this->pipe = $pipe;
$this->path = $path;
$this->server = $server;
$this->stackName = $stackName;
}
public function pipe(callable $middleware)
{
$this->pipe->pipe($this->path, $middleware);
$this->pipe->pipe($middleware);
}
public function isForum()
{
return $this->server instanceof ForumServer;
return $this->stackName === 'forum';
}
public function isAdmin()
{
return $this->server instanceof AdminServer;
return $this->stackName === 'admin';
}
public function isApi()
{
return $this->server instanceof ApiServer;
return $this->stackName === 'api';
}
}