Skip to content

Commit

Permalink
Moved middlewareprovider to http application layer
Browse files Browse the repository at this point in the history
  • Loading branch information
dkraczkowski committed Dec 8, 2018
1 parent 557f5d4 commit 0f207f6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/Application/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Igni\Application\Listeners\OnShutDownListener;
use Igni\Application\Providers\ConfigProvider;
use Igni\Application\Providers\ControllerProvider;
use Igni\Application\Providers\MiddlewareProvider;
use Igni\Application\Providers\ServiceProvider;
use Igni\Container\DependencyResolver;
use Igni\Container\ServiceLocator;
Expand Down Expand Up @@ -188,9 +187,5 @@ protected function initializeModule(&$module): void
if ($module instanceof ServiceProvider) {
$module->provideServices($this->getContainer());
}

if ($module instanceof MiddlewareProvider) {
$module->provideMiddleware($this->getMiddlewareAggregator());
}
}
}
10 changes: 10 additions & 0 deletions src/Application/HttpApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Igni\Application\Http\Controller;
use Igni\Application\Http\MiddlewareAggregator;
use Igni\Application\Http\GenericRouter;
use Igni\Application\Providers\MiddlewareProvider;
use Igni\Network\Http\Middleware\CallableMiddleware;
use Igni\Network\Http\Middleware\ErrorMiddleware;
use Igni\Network\Http\Middleware\MiddlewarePipe;
Expand Down Expand Up @@ -366,6 +367,15 @@ protected function getMiddlewarePipe(): MiddlewarePipe
return $this->pipeline = $this->composeMiddlewarePipe();
}

protected function initializeModule(&$module): void
{
parent::initializeModule($module);

if ($module instanceof MiddlewareProvider) {
$module->provideMiddleware($this->getMiddlewareAggregator());
}
}

private function composeMiddlewarePipe(): MiddlewarePipe
{
$pipe = new MiddlewarePipe();
Expand Down
6 changes: 3 additions & 3 deletions tests/Fixtures/NullApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Igni\Tests\Fixtures;

use Igni\Application\Application;
use Igni\Application\Controller;
use Igni\Application\ControllerAggregator;
use Igni\Application\Http\MiddlewareAggregator;
use Igni\Application\HttpApplication;
use Igni\Container\ServiceLocator;
use Igni\Network\Server\HttpServer;
use Psr\Http\Server\MiddlewareInterface;

class NullApplication extends Application
class NullApplication extends HttpApplication
{
public $onBoot = false;
public $onShutDown = false;
public $onRun = false;

public function run(): void
public function run(HttpServer $server = null): void
{
$this->handleOnBootListeners();
$this->initialize();
Expand Down

0 comments on commit 0f207f6

Please sign in to comment.