This class resolves a string of the format 'class:method' into a closure that can be dispatched.
More...
|
const | CALLABLE_PATTERN = '!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!' |
|
|
| resolveCallable ($class, $method='__invoke') |
| Check if string is something in the DIC that's callable or is a class name which has an __invoke() method. More...
|
|
| assertCallable ($callable) |
|
This class resolves a string of the format 'class:method' into a closure that can be dispatched.
Definition at line 19 of file CallableResolver.php.
◆ __construct()
◆ assertCallable()
Slim\CallableResolver::assertCallable |
( |
|
$callable | ) |
|
|
protected |
- Parameters
-
- Exceptions
-
Definition at line 101 of file CallableResolver.php.
103 if (!is_callable($callable)) {
105 '%s is not resolvable',
106 is_array($callable) || is_object($callable) ? json_encode($callable) : $callable
◆ resolve()
Slim\CallableResolver::resolve |
( |
|
$toResolve | ) |
|
Resolve toResolve into a closure so that the router can dispatch.
If toResolve is of the format 'class:method', then try to extract 'class' from the container otherwise instantiate it and then dispatch 'method'.
- Parameters
-
- Returns
- callable
- Exceptions
-
RuntimeException | if the callable does not exist |
RuntimeException | if the callable is not resolvable |
Implements Slim\Interfaces\CallableResolverInterface.
Definition at line 49 of file CallableResolver.php.
51 if (is_callable($toResolve)) {
55 if (!is_string($toResolve)) {
60 if (preg_match(self::CALLABLE_PATTERN, $toResolve, $matches)) {
assertCallable($callable)
resolveCallable($class, $method='__invoke')
Check if string is something in the DIC that's callable or is a class name which has an __invoke() me...
◆ resolveCallable()
Slim\CallableResolver::resolveCallable |
( |
|
$class, |
|
|
|
$method = '__invoke' |
|
) |
| |
|
protected |
Check if string is something in the DIC that's callable or is a class name which has an __invoke() method.
- Parameters
-
string | $class | |
string | $method | |
- Returns
- callable
- Exceptions
-
Definition at line 83 of file CallableResolver.php.
85 if ($this->container->has($class)) {
86 return [$this->container->get($class), $method];
89 if (!class_exists($class)) {
93 return [
new $class($this->container), $method];
◆ $container
Slim\CallableResolver::$container |
|
private |
◆ CALLABLE_PATTERN
const Slim\CallableResolver::CALLABLE_PATTERN = '!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!' |
The documentation for this class was generated from the following file: