Commit a787ee7a authored by Fabien Potencier's avatar Fabien Potencier

made a small optimization

parent 15b725ce
...@@ -302,20 +302,19 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe ...@@ -302,20 +302,19 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
*/ */
public function mount($prefix, $app) public function mount($prefix, $app)
{ {
$prefix = rtrim($prefix, '/');
$mountHandler = function (Request $request, $prefix) use ($app) { $mountHandler = function (Request $request, $prefix) use ($app) {
if (is_callable($app)) { if (is_callable($app)) {
$app = $app(); $app = $app();
} }
foreach ($app['controllers']->all() as $controller) { foreach ($app['controllers']->all() as $controller) {
$controller->getRoute()->setPattern(rtrim($prefix, '/').$controller->getRoute()->getPattern()); $controller->getRoute()->setPattern($prefix.$controller->getRoute()->getPattern());
} }
return $app->handle($request); return $app->handle($request);
}; };
$prefix = rtrim($prefix, '/');
$this $this
->match($prefix.'/{path}', $mountHandler) ->match($prefix.'/{path}', $mountHandler)
->assert('path', '.*') ->assert('path', '.*')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment