本文整理汇总了PHP中Magento\Framework\App\ResponseInterface::setHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP ResponseInterface::setHeader方法的具体用法?PHP ResponseInterface::setHeader怎么用?PHP ResponseInterface::setHeader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\ResponseInterface
的用法示例。
在下文中一共展示了ResponseInterface::setHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterGetOutput
/**
* Retrieve all identities from blocks for further cache invalidation
*
* @param \Magento\Framework\View\Layout $subject
* @param mixed $result
* @return mixed
*/
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
{
if ($subject->isCacheable() && $this->config->isEnabled()) {
$tags = [];
foreach ($subject->getAllBlocks() as $block) {
if ($block instanceof \Magento\Framework\DataObject\IdentityInterface) {
$isEsiBlock = $block->getTtl() > 0;
$isVarnish = $this->config->getType() == \Magento\PageCache\Model\Config::VARNISH;
if ($isVarnish && $isEsiBlock) {
continue;
}
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
$this->response->setHeader('X-Magento-Tags', implode(',', $tags));
}
return $result;
}
示例2: applyHttpHeaders
/**
* @param ResponseInterface $response
* @return $this
*/
protected function applyHttpHeaders(ResponseInterface $response)
{
if (!empty($this->httpResponseCode)) {
$response->setHttpResponseCode($this->httpResponseCode);
}
if ($this->statusHeaderCode) {
$response->setStatusHeader($this->statusHeaderCode, $this->statusHeaderVersion, $this->statusHeaderPhrase);
}
if (!empty($this->headers)) {
foreach ($this->headers as $headerData) {
$response->setHeader($headerData['name'], $headerData['value'], $headerData['replace']);
}
}
return $this;
}
示例3: sendEmptyRssFeed
/**
* Setting headers to response for sending empty rss
*
* @param \Magento\Framework\App\ResponseInterface $response
* @return void
*/
public function sendEmptyRssFeed(\Magento\Framework\App\ResponseInterface $response)
{
$response->setHeader('HTTP/1.1', '404 Not Found')->setHeader('Status', '404 File not found')->setHeader('Content-Type', 'text/plain; charset=UTF-8')->setBody(__('There was no RSS feed enabled.'));
}