本文整理汇总了PHP中Magento\Framework\App\Response\Http::setNoCacheHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::setNoCacheHeaders方法的具体用法?PHP Http::setNoCacheHeaders怎么用?PHP Http::setNoCacheHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Response\Http
的用法示例。
在下文中一共展示了Http::setNoCacheHeaders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatch
/**
* Perform action and generate response
*
* @param RequestInterface $request
* @return ResponseInterface|\Magento\Framework\Controller\ResultInterface
* @throws \LogicException
*/
public function dispatch(RequestInterface $request)
{
\Magento\Framework\Profiler::start('routers_match');
$routingCycleCounter = 0;
$result = null;
while (!$request->isDispatched() && $routingCycleCounter++ < 100) {
/** @var \Magento\Framework\App\RouterInterface $router */
foreach ($this->_routerList as $router) {
try {
$actionInstance = $router->match($request);
if ($actionInstance) {
$request->setDispatched(true);
$this->response->setNoCacheHeaders();
if ($actionInstance instanceof \Magento\Framework\App\Action\AbstractAction) {
$result = $actionInstance->dispatch($request);
} else {
$result = $actionInstance->execute();
}
break;
}
} catch (\Magento\Framework\Exception\NotFoundException $e) {
$request->initForward();
$request->setActionName('noroute');
$request->setDispatched(false);
break;
}
}
}
\Magento\Framework\Profiler::stop('routers_match');
if ($routingCycleCounter > 100) {
throw new \LogicException('Front controller reached 100 router match iterations');
}
return $result;
}
示例2: setNoCacheHeaders
/**
* {@inheritdoc}
*/
public function setNoCacheHeaders()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'setNoCacheHeaders');
if (!$pluginInfo) {
return parent::setNoCacheHeaders();
} else {
return $this->___callPlugins('setNoCacheHeaders', func_get_args(), $pluginInfo);
}
}
示例3: testSetNoCacheHeaders
/**
* Test setting public cache headers
*/
public function testSetNoCacheHeaders()
{
$timestamp = 1000000;
$pragma = 'no-cache';
$cacheControl = 'max-age=0, must-revalidate, no-cache, no-store';
$expiresResult = 'Thu, 01 Jan 1970 00:00:00 GMT';
$this->dateTimeMock->expects($this->once())->method('strToTime')->with('-1 year')->willReturn($timestamp);
$this->dateTimeMock->expects($this->once())->method('gmDate')->with(Http::EXPIRATION_TIMESTAMP_FORMAT, $timestamp)->willReturn($expiresResult);
$this->model->setNoCacheHeaders();
$this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue());
$this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue());
$this->assertEquals($expiresResult, $this->model->getHeader('Expires')->getFieldValue());
}