本文整理匯總了PHP中Symfony\Component\HttpKernel\HttpCache\HttpCache::terminate方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpCache::terminate方法的具體用法?PHP HttpCache::terminate怎麽用?PHP HttpCache::terminate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpKernel\HttpCache\HttpCache
的用法示例。
在下文中一共展示了HttpCache::terminate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testTerminateDelegatesTerminationOnlyForTerminableInterface
public function testTerminateDelegatesTerminationOnlyForTerminableInterface()
{
$storeMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpCache\\StoreInterface')
->disableOriginalConstructor()
->getMock();
// does not implement TerminableInterface
$kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')
->disableOriginalConstructor()
->getMock();
$kernelMock->expects($this->never())
->method('terminate');
$kernel = new HttpCache($kernelMock, $storeMock);
$kernel->terminate(Request::create('/'), new Response());
// implements TerminableInterface
$kernelMock = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Kernel')
->disableOriginalConstructor()
->setMethods(array('terminate', 'registerBundles', 'registerContainerConfiguration'))
->getMock();
$kernelMock->expects($this->once())
->method('terminate');
$kernel = new HttpCache($kernelMock, $storeMock);
$kernel->terminate(Request::create('/'), new Response());
}
示例2: buildAndCacheResponse
/**
*
*/
protected function buildAndCacheResponse()
{
$controllerResolver = new ControllerResolver(array($this, 'buildResponse'));
$kernel = new HttpKernel(new EventDispatcher(), $controllerResolver);
if ($this->adapter->isCachingEnabled($this->request)) {
$kernel = new HttpCache($kernel, $this->adapter->getStore($this->request), $this->adapter->getSurrogate($this->request), $this->adapter->getHttpCacheOptions($this->request));
}
$response = $kernel->handle($this->request);
$this->shutDownFunctionEnabled = false;
$response->send();
$kernel->terminate($this->request, $response);
}