/** * Compile string handler. * * @param Route $route * @param RequestContext $request * @param string $handler * * @return Response|null * * @throws HttpNotFoundException */ protected function compileStringHandler(Route $route, RequestContext $request, $handler) { $parts = explode(':', $handler); $parameters = array_map('convert_to_camel_case', array_flip((array) $request->getParameters())); $parameters = array_flip($parameters); $action = end($parts); $controller = $this->buildController($handler, $parts, $parameters); if (!method_exists($controller->getOriginalInstance(), $action . 'Action')) { throw new HttpNotFoundException(sprintf('Action "%sAction" not found on controller "%s".', $action, get_class($controller->getOriginalInstance()))); } return $this->dispatchMiddlewares($route, $request, function () use($parameters, $controller, $action) { if (!$this->responseEvent->hasResponse()) { return $controller->callMethod($action . 'Action', $parameters); } return $this->responseEvent->getResponse(); }, $action); }