NelmioApiDocBundle/Extractor/Handler/JmsSecurityExtraHandler.php
Dave Keen 22508bf058 Update JmsSecurityExtraHandler.php
Having a JmsSecurity @PreAuthorize annotation should also count as setting a method as requiring authentication.
2013-04-29 12:10:42 +03:00

31 lines
890 B
PHP

<?php
/*
* This file is part of the NelmioApiDocBundle.
*
* (c) Nelmio <hello@nelm.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\Extractor\Handler;
use JMS\SecurityExtraBundle\Annotation\PreAuthorize;
use Nelmio\ApiDocBundle\Extractor\HandlerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\Routing\Route;
use JMS\SecurityExtraBundle\Annotation\Secure;
class JmsSecurityExtraHandler implements HandlerInterface
{
public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
{
foreach ($annotations as $annot) {
if ($annot instanceof Secure || $annot instanceof PreAuthorize) {
$annotation->setAuthentication(true);
}
}
}
}