mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Add cache annotation extractor
This commit is contained in:
parent
a9087994da
commit
53b2537aef
@ -105,6 +105,11 @@ class ApiDoc
|
|||||||
*/
|
*/
|
||||||
private $authentication = false;
|
private $authentication = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
private $cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
@ -328,6 +333,22 @@ class ApiDoc
|
|||||||
$this->authentication = $authentication;
|
$this->authentication = $authentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getCache()
|
||||||
|
{
|
||||||
|
return $this->cache;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $cache
|
||||||
|
*/
|
||||||
|
public function setCache($cache)
|
||||||
|
{
|
||||||
|
$this->cache = (int) $cache;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -370,6 +391,10 @@ class ApiDoc
|
|||||||
$data['section'] = $section;
|
$data['section'] = $section;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($cache = $this->cache) {
|
||||||
|
$data['cache'] = $cache;
|
||||||
|
}
|
||||||
|
|
||||||
$data['https'] = $this->https;
|
$data['https'] = $this->https;
|
||||||
$data['authentication'] = $this->authentication;
|
$data['authentication'] = $this->authentication;
|
||||||
|
|
||||||
|
@ -30,6 +30,8 @@ class ApiDocExtractor
|
|||||||
|
|
||||||
const JMS_SECURITY_EXTRA_SECURE_CLASS = 'JMS\\SecurityExtraBundle\\Annotation\\Secure';
|
const JMS_SECURITY_EXTRA_SECURE_CLASS = 'JMS\\SecurityExtraBundle\\Annotation\\Secure';
|
||||||
|
|
||||||
|
const CACHE_ANNOTATION_CLASS = 'Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Cache';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ContainerInterface
|
* @var ContainerInterface
|
||||||
*/
|
*/
|
||||||
@ -364,6 +366,8 @@ class ApiDocExtractor
|
|||||||
));
|
));
|
||||||
} elseif (is_a($annot, self::JMS_SECURITY_EXTRA_SECURE_CLASS)) {
|
} elseif (is_a($annot, self::JMS_SECURITY_EXTRA_SECURE_CLASS)) {
|
||||||
$annotation->setAuthentication(true);
|
$annotation->setAuthentication(true);
|
||||||
|
} elseif (is_a($annot, self::CACHE_ANNOTATION_CLASS)) {
|
||||||
|
$annotation->setCache($annot->getMaxAge());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,11 @@
|
|||||||
</table>
|
</table>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if data.cache is defined and data.cache is not empty %}
|
||||||
|
<h4>Cache</h4>
|
||||||
|
<div>{{ data.cache }}s</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if enableSandbox %}
|
{% if enableSandbox %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user