本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Visitor::getResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Visitor::getResponse方法的具体用法?PHP Visitor::getResponse怎么用?PHP Visitor::getResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\REST\Common\Output\Visitor
的用法示例。
在下文中一共展示了Visitor::getResponse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: visit
/**
* @param Visitor $visitor
* @param Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\CachedValue $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$visitor->visitValueObject($data->value);
if ($this->getParameter('content.view_cache') !== true) {
return;
}
$response = $visitor->getResponse();
$response->setPublic();
$response->setVary('Accept');
if ($this->getParameter('content.ttl_cache') === true) {
$response->setSharedMaxAge($this->getParameter('content.default_ttl'));
if (isset($this->request) && $this->request->headers->has('X-User-Hash')) {
$response->setVary('X-User-Hash', false);
}
}
if (isset($data->cacheTags['locationId'])) {
$visitor->getResponse()->headers->set('X-Location-Id', $data->cacheTags['locationId']);
}
}
示例2: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \Netgen\TagsBundle\Core\REST\Server\Values\CachedValue $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$visitor->visitValueObject($data->value);
if ($this->getParameter('tag_view.cache', 'eztags') !== true) {
return;
}
$response = $visitor->getResponse();
$response->setPublic();
$response->setVary('Accept');
if ($this->getParameter('tag_view.ttl_cache', 'eztags') === true) {
$response->setSharedMaxAge($this->getParameter('tag_view.default_ttl', 'eztags'));
$request = $this->getCurrentRequest();
if ($request instanceof Request && $request->headers->has('X-User-Hash')) {
$response->setVary('X-User-Hash', false);
}
}
if (isset($data->cacheTags['tagId'])) {
$response->headers->set('X-Tag-Id', $data->cacheTags['tagId']);
}
if (isset($data->cacheTags['tagKeyword'])) {
$response->headers->set('X-Tag-Keyword', $data->cacheTags['tagKeyword']);
}
}