This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from jeromemacias/master
Use TerminableInterface
- Loading branch information
Showing
2 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,10 @@ | |
|
||
namespace Stack; | ||
|
||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\HttpKernel\TerminableInterface; | ||
|
||
/** | ||
* URL Map Middleware, which maps kernels to paths | ||
|
@@ -12,7 +14,7 @@ | |
* | ||
* @author Christoph Hochstrasser <[email protected]> | ||
*/ | ||
class UrlMap implements HttpKernelInterface | ||
class UrlMap implements HttpKernelInterface, TerminableInterface | ||
{ | ||
const ATTR_PREFIX = "stack.url_map.prefix"; | ||
|
||
|
@@ -69,4 +71,17 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ | |
|
||
return $this->app->handle($request, $type, $catch); | ||
} | ||
|
||
public function terminate(Request $request, Response $response) | ||
{ | ||
foreach ($this->map as $path => $app) { | ||
if ($app instanceof TerminableInterface) { | ||
$app->terminate($request, $response); | ||
} | ||
} | ||
|
||
if ($this->app instanceof TerminableInterface) { | ||
$this->app->terminate($request, $response); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters