NelmioApiDocBundle/Extractor/Handler/SensioFrameworkExtraHandler.php
2014-08-28 00:12:34 +02:00

33 lines
994 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 Nelmio\ApiDocBundle\Extractor\HandlerInterface;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\Routing\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
class SensioFrameworkExtraHandler implements HandlerInterface
{
public function handle(ApiDoc $annotation, array $annotations, Route $route, \ReflectionMethod $method)
{
foreach ($annotations as $annot) {
if ($annot instanceof Cache) {
$annotation->setCache($annot->getMaxAge());
} elseif ($annot instanceof Security) {
$annotation->setAuthentication(true);
}
}
}
}