You are here

class RedirectResponseWithCookie in LDAP Single Sign On 8.4

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

Taken from AlterPHP\Component\HttpFoundation.

Hierarchy

Expanded class hierarchy of RedirectResponseWithCookie

See also

https://github.com/alterphp/components/blob/master/src/AlterPHP/Componen...

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

File

src/RedirectResponseWithCookie.php, line 15

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.