本文整理汇总了PHP中Magento\Framework\App\Response\Http::getHttpResponseCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::getHttpResponseCode方法的具体用法?PHP Http::getHttpResponseCode怎么用?PHP Http::getHttpResponseCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Response\Http
的用法示例。
在下文中一共展示了Http::getHttpResponseCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Modify and cache application response
*
* @param \Magento\Framework\App\Response\Http $response
* @return void
*/
public function process(\Magento\Framework\App\Response\Http $response)
{
if (preg_match('/public.*s-maxage=(\\d+)/', $response->getHeader('Cache-Control')->getFieldValue(), $matches)) {
$maxAge = $matches[1];
$response->setNoCacheHeaders();
if (($response->getHttpResponseCode() == 200 || $response->getHttpResponseCode() == 404) && ($this->request->isGet() || $this->request->isHead())) {
$tagsHeader = $response->getHeader('X-Magento-Tags');
$tags = $tagsHeader ? explode(',', $tagsHeader->getFieldValue()) : [];
$response->clearHeader('Set-Cookie');
$response->clearHeader('X-Magento-Tags');
if (!headers_sent()) {
header_remove('Set-Cookie');
}
$this->cache->save(serialize($response), $this->identifier->getValue(), $tags, $maxAge);
}
}
}
示例2: getHttpResponseCode
/**
* {@inheritdoc}
*/
public function getHttpResponseCode()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getHttpResponseCode');
if (!$pluginInfo) {
return parent::getHttpResponseCode();
} else {
return $this->___callPlugins('getHttpResponseCode', func_get_args(), $pluginInfo);
}
}