ILIAS  release_7 Revision v7.30-3-g800a261c036
CookieJarWrapper.php
Go to the documentation of this file.
1<?php
2
3namespace ILIAS\HTTP\Cookies;
4
5use Dflydev\FigCookies\SetCookies;
6use Psr\Http\Message\ResponseInterface;
7
19{
20
24 private $cookies;
25
26
32 public function __construct(SetCookies $cookies)
33 {
34 $this->cookies = $cookies;
35 }
36
37
41 public function has(string $name) : bool
42 {
43 return $this->cookies->has($name);
44 }
45
46
50 public function get(string $name) : ?\ILIAS\HTTP\Cookies\Cookie
51 {
52 $cookie = $this->cookies->get($name);
53
54 return (is_null($cookie)) ? null : new CookieWrapper($cookie);
55 }
56
57
61 public function getAll() : array
62 {
63 $wrappedCookies = [];
64 foreach ($this->cookies->getAll() as $cookie) {
65 $wrappedCookies[] = new CookieWrapper($cookie);
66 }
67
68 return $wrappedCookies;
69 }
70
71
75 public function with(Cookie $setCookie) : \ILIAS\HTTP\Cookies\CookieJar
76 {
80 $wrapper = $setCookie;
81 $internalCookie = $wrapper->getImplementation();
82
83 $clone = clone $this;
84 $clone->cookies = $this->cookies->with($internalCookie);
85
86 return $clone;
87 }
88
89
93 public function without(string $name) : \ILIAS\HTTP\Cookies\CookieJar
94 {
95 $clone = clone $this;
96 $clone->cookies = $this->cookies->without($name);
97
98 return $clone;
99 }
100
101
105 public function renderIntoResponseHeader(ResponseInterface $response) : \Psr\Http\Message\ResponseInterface
106 {
107 $response = $this->cookies->renderIntoSetCookieHeader($response);
108
109 return $response;
110 }
111}
An exception for terminatinating execution or to throw for unit testing.
renderIntoResponseHeader(ResponseInterface $response)
@inheritDoc
__construct(SetCookies $cookies)
CookieJarWrapper constructor.
without(string $name)
@inheritDoc
with(Cookie $setCookie)
Creates a new cookie jar with the given cookie.
without(string $name)
Creates a cookie jar without the specified cookie.
if($format !==null) $name
Definition: metadata.php:230
Class CookieJarWrapperTest.
Definition: Cookie.php:3
Class ChatMainBarProvider \MainMenu\Provider.
$response