Invoker\CallableResolver::resolve PHP Method

resolve() public method

Resolve the given callable into a real PHP callable.
public resolve ( callable | string | array $callable ) : callable
$callable callable | string | array
return callable Real PHP callable.
    public function resolve($callable)
    {
        if (is_string($callable) && strpos($callable, '::') !== false) {
            $callable = explode('::', $callable, 2);
        }
        $callable = $this->resolveFromContainer($callable);
        if (!is_callable($callable)) {
            throw NotCallableException::fromInvalidCallable($callable, true);
        }
        return $callable;
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function getController(Request $request)
 {
     if (!($controller = $request->attributes->get('_controller'))) {
         throw new \LogicException(sprintf('Controller for URI "%s" could not be found because the "_controller" parameter is missing.', $request->getPathInfo()));
     }
     try {
         return $this->callableResolver->resolve($controller);
     } catch (NotCallableException $e) {
         throw new \InvalidArgumentException(sprintf('Controller for URI "%s" is not callable: %s', $request->getPathInfo(), $e->getMessage()));
     }
 }
All Usage Examples Of Invoker\CallableResolver::resolve