Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Aug 5, 2019
1 parent eca7ccf commit 00c64bc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public static function create(ContainerInterface $container = null): App

$app = AppFactory::create();

$controllerInvoker = self::createControllerInvoker($container);
$app->getRouteCollector()->setDefaultInvocationStrategy($controllerInvoker);

return $app;
}

private static function createControllerInvoker(ContainerInterface $container): ControllerInvoker
{
$resolvers = [
// Inject parameters by name first
new AssociativeArrayResolver(),
Expand All @@ -41,8 +49,7 @@ public static function create(ContainerInterface $container = null): App
];

$invoker = new Invoker(new ResolverChain($resolvers), $container);
$app->getRouteCollector()->setDefaultInvocationStrategy(new ControllerInvoker($invoker));

return $app;
return new ControllerInvoker($invoker);
}
}

0 comments on commit 00c64bc

Please sign in to comment.