-
-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f43fed4
commit 0e09ec0
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor; | ||
|
||
use Doctrine\Common\Util\ClassUtils; | ||
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor as BaseApiDocExtractor; | ||
use Symfony\Component\HttpFoundation\Request; | ||
|
||
class ApiDocExtractor extends BaseApiDocExtractor | ||
{ | ||
public function getReflectionMethod($controller) | ||
{ | ||
$reflectionMethod = parent::getReflectionMethod($controller); | ||
if (null !== $reflectionMethod) { | ||
return $reflectionMethod; | ||
} | ||
|
||
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'; | ||
} | ||
} | ||
|
||
if (isset($class) && isset($method)) { | ||
try { | ||
return new \ReflectionMethod($class, $method); | ||
} catch (\ReflectionException $e) { | ||
} | ||
} | ||
|
||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters