mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 07:33:36 +08:00
Use instance variable directly instead of passing it around
This commit is contained in:
parent
df6f10da20
commit
30bc979fcb
|
@ -46,7 +46,7 @@ class ControllerRouteHandler
|
||||||
*/
|
*/
|
||||||
public function __invoke(ServerRequestInterface $request, array $routeParams)
|
public function __invoke(ServerRequestInterface $request, array $routeParams)
|
||||||
{
|
{
|
||||||
$controller = $this->resolveController($this->controller);
|
$controller = $this->resolveController();
|
||||||
|
|
||||||
$request = $request->withQueryParams(array_merge($request->getQueryParams(), $routeParams));
|
$request = $request->withQueryParams(array_merge($request->getQueryParams(), $routeParams));
|
||||||
|
|
||||||
|
@ -54,15 +54,14 @@ class ControllerRouteHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|callable $class
|
|
||||||
* @return RequestHandlerInterface
|
* @return RequestHandlerInterface
|
||||||
*/
|
*/
|
||||||
protected function resolveController($class)
|
protected function resolveController()
|
||||||
{
|
{
|
||||||
if (is_callable($class)) {
|
if (is_callable($this->controller)) {
|
||||||
$controller = $this->container->call($class);
|
$controller = $this->container->call($this->controller);
|
||||||
} else {
|
} else {
|
||||||
$controller = $this->container->make($class);
|
$controller = $this->container->make($this->controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ($controller instanceof RequestHandlerInterface)) {
|
if (! ($controller instanceof RequestHandlerInterface)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user