Update JmsSecurityExtraHandler.php

Having a JmsSecurity @PreAuthorize annotation should also count as setting a method as requiring authentication.
This commit is contained in:
Dave Keen 2013-04-29 12:10:42 +03:00
parent 42f0b65a4a
commit 22508bf058

View File

@ -11,6 +11,7 @@
namespace Nelmio\ApiDocBundle\Extractor\Handler; namespace Nelmio\ApiDocBundle\Extractor\Handler;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
use Nelmio\ApiDocBundle\Extractor\HandlerInterface; use Nelmio\ApiDocBundle\Extractor\HandlerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\Routing\Route; use Symfony\Component\Routing\Route;
@ -21,7 +22,7 @@ class JmsSecurityExtraHandler implements HandlerInterface
public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method) public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
{ {
foreach ($annotations as $annot) { foreach ($annotations as $annot) {
if ($annot instanceof Secure) { if ($annot instanceof Secure || $annot instanceof PreAuthorize) {
$annotation->setAuthentication(true); $annotation->setAuthentication(true);
} }
} }