Add cache annotation extractor

This commit is contained in:
Florent DUBOST 2013-03-26 11:49:12 +01:00
parent a9087994da
commit 53b2537aef
3 changed files with 37 additions and 3 deletions

View File

@ -105,6 +105,11 @@ class ApiDoc
*/
private $authentication = false;
/**
* @var int
*/
private $cache;
/**
* @var array
*/
@ -328,6 +333,22 @@ class ApiDoc
$this->authentication = $authentication;
}
/**
* @return int
*/
public function getCache()
{
return $this->cache;
}
/**
* @param int $cache
*/
public function setCache($cache)
{
$this->cache = (int) $cache;
}
/**
* @return array
*/
@ -370,6 +391,10 @@ class ApiDoc
$data['section'] = $section;
}
if ($cache = $this->cache) {
$data['cache'] = $cache;
}
$data['https'] = $this->https;
$data['authentication'] = $this->authentication;

View File

@ -22,14 +22,16 @@ use Nelmio\ApiDocBundle\Util\DocCommentExtractor;
class ApiDocExtractor
{
const ANNOTATION_CLASS = 'Nelmio\\ApiDocBundle\\Annotation\\ApiDoc';
const ANNOTATION_CLASS = 'Nelmio\\ApiDocBundle\\Annotation\\ApiDoc';
const FOS_REST_QUERY_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\QueryParam';
const FOS_REST_QUERY_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\QueryParam';
const FOS_REST_REQUEST_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\RequestParam';
const FOS_REST_REQUEST_PARAM_CLASS = 'FOS\\RestBundle\\Controller\\Annotations\\RequestParam';
const JMS_SECURITY_EXTRA_SECURE_CLASS = 'JMS\\SecurityExtraBundle\\Annotation\\Secure';
const CACHE_ANNOTATION_CLASS = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache';
/**
* @var ContainerInterface
*/
@ -364,6 +366,8 @@ class ApiDocExtractor
));
} elseif (is_a($annot, self::JMS_SECURITY_EXTRA_SECURE_CLASS)) {
$annotation->setAuthentication(true);
} elseif (is_a($annot, self::CACHE_ANNOTATION_CLASS)) {
$annotation->setCache($annot->getMaxAge());
}
}
}

View File

@ -165,6 +165,11 @@
</table>
{% endif %}
{% if data.cache is defined and data.cache is not empty %}
<h4>Cache</h4>
<div>{{ data.cache }}s</div>
{% endif %}
</div>
{% if enableSandbox %}