Fix ApiDocExtractor to accept callable classes as controllers

This commit is contained in:
maxime.steinhausser 2015-08-11 15:24:36 +02:00
parent 4351ca66d3
commit 6f4373cda4

View File

@ -211,14 +211,20 @@ class ApiDocExtractor
if (preg_match('#(.+)::([\w]+)#', $controller, $matches)) {
$class = $matches[1];
$method = $matches[2];
} elseif (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
$controller = $matches[1];
$method = $matches[2];
} else {
if (preg_match('#(.+):([\w]+)#', $controller, $matches)) {
$controller = $matches[1];
$method = $matches[2];
}
if ($this->container->has($controller)) {
$this->container->enterScope('request');
$this->container->set('request', new Request(), 'request');
$class = ClassUtils::getRealClass(get_class($this->container->get($controller)));
$this->container->leaveScope('request');
if (!isset($method) && method_exists($class, '__invoke')) {
$method = '__invoke';
}
}
}