12345678910111213141516171819202122232425262728 |
- <?php
- namespace demo\Middleware;
- use Silex\Application;
- use Symfony\Component\HttpFoundation\Request;
- use Symfony\Component\HttpFoundation\Response;
- class AfterRoute {
- public static function next(Request $request, Response $response, Application $app) {
- $MESSAGE = "<p>" . $app['timer']->delay() .": in aR</p>\n";
- $content = $response->getContent();
- if ($content !== FALSE) {
- $content .= $MESSAGE;
- $response->setContent($content);
- }
- else {
- // Only echo info on text responses.
- $ct = $response->headers->get('Content-Type');
- if (isset($ct) && strpos($ct, 'text') !== 0) {
- return;
- }
- echo $MESSAGE;
- flush();
- }
- }
- }
|