1
0
mirror of https://github.com/flarum/core.git synced 2025-07-20 08:11:27 +02:00

AbstractServer: Store app instance as class property

This will make it easier to reuse the instance in an asynchronous
setting (e.g. ReactPHP), where one application instance is preloaded
and reused for each incoming request.
This commit is contained in:
Franz Liedke
2016-04-16 13:07:52 +09:00
parent 120821efcd
commit 04aef5814e
2 changed files with 9 additions and 4 deletions

View File

@@ -17,6 +17,11 @@ use Monolog\Logger;
abstract class AbstractServer abstract class AbstractServer
{ {
/**
* @var Application
*/
protected $app;
/** /**
* @var string * @var string
*/ */
@@ -41,6 +46,8 @@ abstract class AbstractServer
if (file_exists($file = $this->path.'/config.php')) { if (file_exists($file = $this->path.'/config.php')) {
$this->config = include $file; $this->config = include $file;
} }
$this->app = $this->getApp();
} }
/** /**

View File

@@ -22,12 +22,10 @@ abstract class AbstractServer extends BaseAbstractServer
{ {
public function listen() public function listen()
{ {
$app = $this->getApp(); $this->collectGarbage($this->app);
$this->collectGarbage($app);
$server = Server::createServer( $server = Server::createServer(
$this->getMiddleware($app), $this->getMiddleware($this->app),
$_SERVER, $_SERVER,
$_GET, $_GET,
$_POST, $_POST,