ILIAS  release_8 Revision v8.24
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
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 *****************************************************************************/
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}
renderIntoResponseHeader(ResponseInterface $response)
@inheritDoc
__construct(SetCookies $cookies)
CookieJarWrapper constructor.
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:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Cookie.php:19
Class ChatMainBarProvider \MainMenu\Provider.
$response