ILIAS  release_7 Revision v7.30-3-g800a261c036
HTTPServices.php
Go to the documentation of this file.
1<?php
18namespace ILIAS\DI;
19
26use Psr\Http\Message\ResponseInterface;
27use Psr\Http\Message\ServerRequestInterface;
28
35{
36
40 private $sender;
56 private $request;
60 private $response;
61
62
72 {
73 $this->sender = $senderStrategy;
74 $this->cookieJarFactory = $cookieJarFactory;
75
76 $this->requestFactory = $requestFactory;
77 $this->responseFactory = $responseFactory;
78 }
79
80
84 public function cookieJar() : CookieJar
85 {
86 return $this->cookieJarFactory->fromResponse($this->response());
87 }
88
89
93 public function request() : \Psr\Http\Message\RequestInterface
94 {
95 if ($this->request === null) {
96 $this->request = $this->requestFactory->create();
97 }
98
99 return $this->request;
100 }
101
102
106 public function response() : ResponseInterface
107 {
108 if ($this->response === null) {
109 $this->response = $this->responseFactory->create();
110 }
111
112 return $this->response;
113 }
114
115
119 public function saveRequest(ServerRequestInterface $request) : void
120 {
121 $this->request = $request;
122 }
123
124
128 public function saveResponse(ResponseInterface $response) : void
129 {
130 $this->response = $response;
131 }
132
133
137 public function sendResponse() : void
138 {
139 // Render Cookies to the response.
140 $response = $this->response();
141 $response = $this->cookieJar()->renderIntoResponseHeader($response);
142
143 $this->sender->sendResponse($response);
144 }
145
146
147 public function close() : void
148 {
149 exit;
150 }
151}
An exception for terminatinating execution or to throw for unit testing.
Provides an interface to the ILIAS HTTP services.
__construct(ResponseSenderStrategy $senderStrategy, CookieJarFactory $cookieJarFactory, RequestFactory $requestFactory, ResponseFactory $responseFactory)
HTTPServices constructor.
sendResponse()
@inheritDoc
request()
@inheritDoc
cookieJar()
@inheritDoc
saveRequest(ServerRequestInterface $request)
@inheritDoc
saveResponse(ResponseInterface $response)
@inheritDoc
Interface GlobalHttpState.
exit
Definition: login.php:29
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...