-
Notifications
You must be signed in to change notification settings - Fork 81
/
CallableDispatcher.php
54 lines (47 loc) · 1.34 KB
/
CallableDispatcher.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Illuminate\Routing;
use Illuminate\Container\Container;
use Illuminate\Routing\Contracts\CallableDispatcher as CallableDispatcherContract;
use ReflectionFunction;
class CallableDispatcher implements CallableDispatcherContract
{
use ResolvesRouteDependencies;
/**
* The container instance.
*
* @var \Illuminate\Container\Container
*/
protected $container;
/**
* Create a new callable dispatcher instance.
*
* @param \Illuminate\Container\Container $container
* @return void
*/
public function __construct(Container $container)
{
$this->container = $container;
}
/**
* Dispatch a request to a given callable.
*
* @param \Illuminate\Routing\Route $route
* @param callable $callable
* @return mixed
*/
public function dispatch(Route $route, $callable)
{
return $callable(...array_values($this->resolveParameters($route, $callable)));
}
/**
* Resolve the parameters for the callable.
*
* @param \Illuminate\Routing\Route $route
* @param callable $callable
* @return array
*/
protected function resolveParameters(Route $route, $callable)
{
return $this->resolveMethodDependencies($route->parametersWithoutNulls(), new ReflectionFunction($callable));
}
}