ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
CookieJarWrapper.php
Go to the documentation of this file.
1 <?php
2 
3 namespace ILIAS\HTTP\Cookies;
4 
7 
8 /******************************************************************************
9  *
10  * This file is part of ILIAS, a powerful learning management system.
11  *
12  * ILIAS is licensed with the GPL-3.0, you should have received a copy
13  * of said license along with the source code.
14  *
15  * If this is not the case or you just want to try ILIAS, you'll find
16  * us at:
17  * https://www.ilias.de
18  * https://github.com/ILIAS-eLearning
19  *
20  *****************************************************************************/
31 class CookieJarWrapper implements CookieJar
32 {
33  private SetCookies $cookies;
34 
35 
39  public function __construct(SetCookies $cookies)
40  {
41  $this->cookies = $cookies;
42  }
43 
44 
48  public function has(string $name): bool
49  {
50  return $this->cookies->has($name);
51  }
52 
53 
57  public function get(string $name): ?\ILIAS\HTTP\Cookies\Cookie
58  {
59  $cookie = $this->cookies->get($name);
60 
61  return (is_null($cookie)) ? null : new CookieWrapper($cookie);
62  }
63 
64 
68  public function getAll(): array
69  {
70  $wrappedCookies = [];
71  foreach ($this->cookies->getAll() as $cookie) {
72  $wrappedCookies[] = new CookieWrapper($cookie);
73  }
74 
75  return $wrappedCookies;
76  }
77 
78 
82  public function with(Cookie $setCookie): CookieJar
83  {
87  $wrapper = $setCookie;
88  $internalCookie = $wrapper->getImplementation();
89 
90  $clone = clone $this;
91  $clone->cookies = $this->cookies->with($internalCookie);
92 
93  return $clone;
94  }
95 
96 
100  public function without(string $name): CookieJar
101  {
102  $clone = clone $this;
103  $clone->cookies = $this->cookies->without($name);
104 
105  return $clone;
106  }
107 
108 
112  public function renderIntoResponseHeader(ResponseInterface $response): ResponseInterface
113  {
114  return $this->cookies->renderIntoSetCookieHeader($response);
115  }
116 }
Class ChatMainBarProvider .
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Cookie.php:19
if($format !==null) $name
Definition: metadata.php:247
renderIntoResponseHeader(ResponseInterface $response)
without(string $name)
Creates a cookie jar without the specified cookie.
with(Cookie $setCookie)
Creates a new cookie jar with the given cookie.
__construct(SetCookies $cookies)
CookieJarWrapper constructor.
$response