/** * Create a new Cookie jar from an associative array and domain. * * @param array $cookies Cookies to create the jar from * @param string $domain Domain to set the cookies to * * @return self */ public static function fromArray(array $cookies, $domain) { $cookieJar = new self(); foreach ($cookies as $name => $value) { $cookieJar->setCookie(new SetCookie(['Domain' => $domain, 'Name' => $name, 'Value' => $value, 'Discard' => true])); } return $cookieJar; }
public static function createFromGlobals() { $request = new self(); $request->setGet(new ParameterBag($_GET)); $request->setPost(new ParameterBag($_POST)); $request->setCookie(new ParameterBag($_COOKIE)); $request->setSession(new ParameterBag($_SESSION)); $request->setServer(new ParameterBag($_SERVER)); $request->setFile(new ParameterBag($_FILES)); return $request; }