fromResponse example


  public static function createFromRedirectResponse(RedirectResponse $response) {
    $safe_response = new static($response->getTargetUrl()$response->getStatusCode()$response->headers->allPreserveCase());
    $safe_response->fromResponse($response);
    return $safe_response;
  }

  /** * Copies over the values from the given response. * * @param \Symfony\Component\HttpFoundation\RedirectResponse $response * The redirect response object. */
  protected function fromResponse(RedirectResponse $response) {
    $this->setProtocolVersion($response->getProtocolVersion());
    
/** * Provides a common base class for cacheable safe redirects. */
abstract class CacheableSecuredRedirectResponse extends SecuredRedirectResponse implements CacheableResponseInterface {

  use CacheableResponseTrait;

  /** * {@inheritdoc} */
  protected function fromResponse(RedirectResponse $response) {
    parent::fromResponse($response);

    $metadata = $this->getCacheableMetadata();
    if ($response instanceof CacheableResponseInterface) {
      $metadata->addCacheableDependency($response->getCacheableMetadata());
    }
    else {
      $metadata->setCacheMaxAge(0);
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.