diff --git a/developer_manual/basics/middlewares.rst b/developer_manual/basics/middlewares.rst index 6df5e09b9..6a38da9c1 100644 --- a/developer_manual/basics/middlewares.rst +++ b/developer_manual/basics/middlewares.rst @@ -11,6 +11,9 @@ Middleware is logic that is run before and after each request and is modelled af * ``afterController``: This is being run after a successful controller method call and allows the manipulation of a Response object. The middleware is run in reverse order * ``beforeOutput``: This is being run after the response object has been rendered and allows the manipulation of the outputted text. The middleware is run in reverse order +.. figure:: ../images/middleware-flow-horiz.png + :alt: Middleware flow chart + To generate your own middleware, simply inherit from the Middleware class and overwrite the methods that should be used. @@ -128,7 +131,7 @@ Middlewares can also be added using the **registerMiddleware** method of the con public function __construct(array $urlParams = []) { parent::__construct('myapp', $urlParams); - + $container = $this->getContainer(); // executed in the order that it is registered @@ -142,7 +145,7 @@ Middlewares can also be added using the **registerMiddleware** method of the con The order is important! The middleware that is registered first gets run first in the **beforeController** method. For all other hooks, the order is being reversed, meaning: if a middleware is registered first, it gets run last. -Parsing annotations +Parsing annotations ------------------- Sometimes it is useful to conditionally execute code before or after a controller method. This can be done by defining custom annotations. An example would be to add a custom authentication method or simply add an additional header to the response. To access the parsed annotations, inject the **ControllerMethodReflector** class: diff --git a/developer_manual/images/middleware-flow-horiz.png b/developer_manual/images/middleware-flow-horiz.png new file mode 100644 index 000000000..5a09c1371 Binary files /dev/null and b/developer_manual/images/middleware-flow-horiz.png differ