ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
CookieJarWrapper.php
Go to the documentation of this file.
1 <?php
2 
19 namespace ILIAS\HTTP\Cookies;
20 
23 
34 class CookieJarWrapper implements CookieJar
35 {
39  public function __construct(private SetCookies $cookies)
40  {
41  }
42 
43 
47  public function has(string $name): bool
48  {
49  return $this->cookies->has($name);
50  }
51 
52 
56  public function get(string $name): ?Cookie
57  {
58  $cookie = $this->cookies->get($name);
59 
60  return (is_null($cookie)) ? null : new CookieWrapper($cookie);
61  }
62 
63 
67  public function getAll(): array
68  {
69  $wrappedCookies = [];
70  foreach ($this->cookies->getAll() as $cookie) {
71  $wrappedCookies[] = new CookieWrapper($cookie);
72  }
73 
74  return $wrappedCookies;
75  }
76 
77 
81  public function with(Cookie $setCookie): CookieJar
82  {
86  $wrapper = $setCookie;
87  $internalCookie = $wrapper->getImplementation();
88 
89  $clone = clone $this;
90  $clone->cookies = $this->cookies->with($internalCookie);
91 
92  return $clone;
93  }
94 
95 
99  public function without(string $name): CookieJar
100  {
101  $clone = clone $this;
102  $clone->cookies = $this->cookies->without($name);
103 
104  return $clone;
105  }
106 
107 
111  public function renderIntoResponseHeader(ResponseInterface $response): ResponseInterface
112  {
113  return $this->cookies->renderIntoSetCookieHeader($response);
114  }
115 }
$response
Definition: xapitoken.php:93
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Cookie.php:19
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
renderIntoResponseHeader(ResponseInterface $response)
__construct(private SetCookies $cookies)
CookieJarWrapper constructor.
without(string $name)
Creates a cookie jar without the specified cookie.
with(Cookie $setCookie)
Creates a new cookie jar with the given cookie.