diff --git a/docs/flow.md b/docs/flow.md index fdcea6b..620c1f3 100644 --- a/docs/flow.md +++ b/docs/flow.md @@ -37,7 +37,7 @@ require_once "./vendor/autoload.php"; $app = new \GianArb\Penny\App(); -$app->getContainer()->get("http.flow")->attach("*", function ($event) { +$app->getContainer()->get("event_manager")->attach("*", function ($event) { $e = $event->getException(); if ($e instanceof Exception) { throw $e; diff --git a/src/App.php b/src/App.php index 2f5fb43..670c11d 100644 --- a/src/App.php +++ b/src/App.php @@ -65,7 +65,7 @@ public function __construct($router = null, ContainerInterface $container = null $container->set('router', $router); } - $container->set('http.flow', DI\object('Zend\EventManager\EventManager')); + $container->set('event_manager', DI\object('Zend\EventManager\EventManager')); $container->set('dispatcher', DI\object('GianArb\Penny\Dispatcher') ->constructor($container->get('router'))); $container->set('di', $container); @@ -117,11 +117,11 @@ private function getDispatcher() * * @return HttpFlowEvent */ - private function getHttpFlow() + private function getEventManager() { $container = $this->container; - return $container->get('http.flow'); + return $container->get('event_manager'); } /** @@ -140,7 +140,7 @@ public function run($request = null, $response = null) $container = $this->getContainer(); $dispatcher = $this->getDispatcher(); - $httpFlow = $this->getHttpFlow(); + $httpFlow = $this->getEventManager(); try { $routerInfo = $dispatcher->dispatch($request); diff --git a/tests/AppTest.php b/tests/AppTest.php index f7b82aa..1453f0b 100644 --- a/tests/AppTest.php +++ b/tests/AppTest.php @@ -26,7 +26,7 @@ public function setUp() $this->app = new App($router); - $this->app->getContainer()->get('http.flow')->attach('ERROR_DISPATCH', function ($e) { + $this->app->getContainer()->get('event_manager')->attach('ERROR_DISPATCH', function ($e) { if ($e->getException() instanceof RouteNotFound) { $response = $e->getResponse()->withStatus(404); $e->setResponse($response); @@ -84,7 +84,7 @@ public function testEventPostExecuted() ->withMethod('GET'); $response = new Response(); - $this->app->getContainer()->get('http.flow')->attach('index.index', function ($e) { + $this->app->getContainer()->get('event_manager')->attach('index.index', function ($e) { $response = $e->getResponse(); $response->getBody()->write("I'm very happy!"); $e->setResponse($response); @@ -102,7 +102,7 @@ public function testEventPreExecuted() ->withMethod('GET'); $response = new Response(); - $this->app->getContainer()->get('http.flow')->attach('index.index', function ($e) { + $this->app->getContainer()->get('event_manager')->attach('index.index', function ($e) { $response = $e->getResponse(); $response->getBody()->write('This is'); $e->setResponse($response); @@ -122,7 +122,7 @@ public function testEventPreThrowExceptionIsTrigger() $response = new Response(); $count = 0; - $this->app->getContainer()->get('http.flow')->attach('index.dummy_error', function ($e) use (&$count) { + $this->app->getContainer()->get('event_manager')->attach('index.dummy_error', function ($e) use (&$count) { $count = &$count + 1; throw $e->getException(); }, 10); diff --git a/tests/EventFlowTest.php b/tests/EventFlowTest.php index e37161f..3b4b482 100644 --- a/tests/EventFlowTest.php +++ b/tests/EventFlowTest.php @@ -30,13 +30,13 @@ public function testStopEventFlow() { ->withMethod('GET'); $response = new Response(); - $this->app->getContainer()->get('http.flow')->attach('index.index', function ($e) { + $this->app->getContainer()->get('event_manager')->attach('index.index', function ($e) { $response = $e->getResponse(); $response = $response->withStatus(201); $e->setResponse($response); }, 100); - $this->app->getContainer()->get('http.flow')->attach('index.index', function ($e) { + $this->app->getContainer()->get('event_manager')->attach('index.index', function ($e) { $response = $e->getResponse(); $response = $response->withStatus(205); $e->setResponse($response); diff --git a/tests/Http/SymfonyKernelTest.php b/tests/Http/SymfonyKernelTest.php index 00e9f07..b9affc9 100644 --- a/tests/Http/SymfonyKernelTest.php +++ b/tests/Http/SymfonyKernelTest.php @@ -26,7 +26,7 @@ public function testRunErrorReturnSameHttpObjects() $requestTest = null; $responseTest = null; - $this->app->getContainer()->get("http.flow")->attach("symfonykerneltest.index_error", function ($e) use (&$requestTest, &$responseTest) { + $this->app->getContainer()->get("event_manager")->attach("symfonykerneltest.index_error", function ($e) use (&$requestTest, &$responseTest) { $requestTest = $e->getRequest(); $responseTest = $e->getResponse(); });