Skip to content

Commit 3cc4f36

Browse files
committed
[HttpKernel] Extract method to make callable controller in ControllerResolver
correct naming
1 parent 436f2c7 commit 3cc4f36

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Controller/ControllerResolver.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getController(Request $request)
7878

7979
if (false === strpos($controller, ':')) {
8080
if (method_exists($controller, '__invoke')) {
81-
return new $controller();
81+
return $this->instantiateController($controller);
8282
} elseif (function_exists($controller)) {
8383
return $controller;
8484
}
@@ -167,6 +167,18 @@ protected function createController($controller)
167167
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
168168
}
169169

170-
return array(new $class(), $method);
170+
return array($this->instantiateController($class), $method);
171+
}
172+
173+
/**
174+
* Returns an instantiated controller
175+
*
176+
* @param string $class A class name
177+
*
178+
* @return object
179+
*/
180+
protected function instantiateController($class)
181+
{
182+
return new $class();
171183
}
172184
}

0 commit comments

Comments
 (0)