mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Add cache annotation extractor
This commit is contained in:
parent
a9087994da
commit
53b2537aef
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user