You are here

class RedirectResponseWithCookie in LDAP Single Sign On 8

Same name and namespace in other branches
  1. 8.4 src/RedirectResponseWithCookie.php \Drupal\ldap_sso\RedirectResponseWithCookie

An HTTP response doing a redirect and sending cookies.

@package AlterPHP.Component

@subpackage HttpFoundation

@author pcb <pc.bertineau@alterphp.com>

Hierarchy

Expanded class hierarchy of RedirectResponseWithCookie

1 file declares its use of RedirectResponseWithCookie
LoginController.php in src/Controller/LoginController.php

File

src/RedirectResponseWithCookie.php, line 17

Namespace

Drupal\ldap_sso
View source
class RedirectResponseWithCookie extends RedirectResponse {

  /**
   * Creates a valid redirect response and pushes cookies with them.
   *
   * @param string $url
   *   The URL to redirect to.
   * @param int $status
   *   The status code (302 by default)
   * @param array $cookies
   *   An array of Cookie objects.
   */
  public function __construct($url, $status = 302, array $cookies = []) {
    parent::__construct($url, $status);
    foreach ($cookies as $cookie) {
      if (!$cookie instanceof Cookie) {
        throw new \InvalidArgumentException(sprintf('One of third parameter array is not a valid Cookie object.'));
      }
      $this->headers
        ->setCookie($cookie);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RedirectResponseWithCookie::__construct public function Creates a valid redirect response and pushes cookies with them.