コード例 #1
0
 /**
  * Get cache response.
  *
  * Set $lifetime as < 0 for not set max-age
  *
  * @param mixed $params
  * @param int $lifetime
  * @param Response|null $response
  *
  * @return Response
  */
 public function getResponse($params = [], $lifetime = -1, Response $response = null)
 {
     if (!$response) {
         $response = new Response();
     }
     if (!$this->enable) {
         return $response;
     }
     return $this->configurator->configure($response, $this->getMax($params), $lifetime);
 }
コード例 #2
0
 public function testConfigureNoRequest()
 {
     $response = new Response();
     $expected_response = clone $response;
     $this->request_stack->expects($this->once())->method('getMasterRequest')->will($this->returnValue(null));
     $configurator = new ResponseConfigurator($this->key_builder, $this->request_stack, []);
     $this->assertEquals($expected_response, $configurator->configure($response, new \DateTime(), -1));
 }