/** * Prepare response. * * @param Response|ResponseBody|string $response * @return Response */ protected function prepareResponse($response) { if (!$response instanceof Response) { $response = new Response($response); } $c = $this->container->get('config'); return $response->setCookiePath($c->get('cookie.path', $c->get('routing.base', $this->container->get('router')->getBase())))->setCookieDomain($c->get('cookie.domain')); }
/** * {@inheritdoc} */ public function prepare(Response $response, $buffer = null) { if ($this->headers) { $response->header('Content-Type', $this->contentType); if ($this->asAttachment) { $response->header('Content-Disposition', 'attachment; filename="' . $this->name . '"'); } if ($this->contentLength) { $response->header('Content-Length', $this->contentLength); } } }
/** * {@inheritdoc} */ public function prepare(Response $response, $buffer = null) { $file = $this->fileName ? $this->fileName : date('Y-m-d'); $response->header('Content-Type', 'text/csv; charset=' . $this->charset); $response->header('Content-disposition', 'attachment; filename=' . $file . '.csv'); $response->header('Pragma', 'no-cache'); }
/** * {@inheritdoc} */ public function prepare(Response $response, $buffer = null) { $response->header('Content-Type', 'application/json; charset=UTF-8'); $this->encoded = json_encode($this->data); }
/** * Close session and save data. */ public function close(Response $response) { if ($this->id) { if ($this->isRefreshReady()) { $this->backend->delete($this->id); $this->id = TokenGenerator::get(); $this->data['refreshTime'] = time(); $this->data['refreshVisits'] = 0; } $this->data['refreshVisits']++; $this->data['lastQuery'] = $this->request->url(); $this->data['lastTime'] = time(); $this->backend->save($this->id, $this->data, $this->ttl); $response->cookie($this->cookie, $this->id, time() + $this->ttl); } if (rand() / getrandmax() < $this->gcProbability) { $this->backend->clear($this->ttl); } $this->closed = true; }
/** * {@inheritdoc} */ public function prepare(Response $response, $buffer = null) { $response->header('Content-Type', 'text/html; charset=UTF-8'); $this->set('debug', $buffer); }
/** * Register autologed session for currently authorized user. * * @return self */ public function forget(Request $request, Response $response) { if (!$this->autologin) { throw new \BadMethodCallException('To use AutoLogin functionality provide instance of AutologinProvider.'); } if ($key = $request->cookie($this->autologinCookie)) { $response->cookie($this->autologinCookie, '', 1); $this->autologin->delete($key); } return $this; }
/** * {@inheritdoc} */ public function prepare(Response $response, $buffer = null) { $response->header('Content-Type', $this->format . '; charset=UTF-8'); $this->set('signature', $this->getSignatureKey()); $this->set('buffer', $buffer); $this->compiled = $this->render(); }