Skip to content

Commit

Permalink
Merge pull request #1428 from silentworks/feature/lazy-resolve-callable
Browse files Browse the repository at this point in the history
Lazily resolve the callable for better performance
  • Loading branch information
codeguy committed Aug 11, 2015
2 parents 4bd179c + d7693b0 commit b671071
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion Slim/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ public function any($pattern, $callable)
*/
public function map(array $methods, $pattern, $callable)
{
$callable = is_string($callable) ? $this->resolveCallable($callable) : $callable;
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this);
}
Expand Down
4 changes: 4 additions & 0 deletions Slim/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ public function run(ServerRequestInterface $request, ResponseInterface $response
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
{
if (is_string($this->callable)) {
$this->callable = $this->resolveCallable($this->callable);
}

/** @var InvocationStrategyInterface $handler */
$handler = isset($this->container) ? $this->container->get('foundHandler') : new RequestResponse();

Expand Down

0 comments on commit b671071

Please sign in to comment.