ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
HTTPServices.php
Go to the documentation of this file.
1 <?php
18 namespace ILIAS\DI;
19 
28 
34 class HTTPServices implements GlobalHttpState
35 {
36 
40  private $sender;
48  private $requestFactory;
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 }
Interface GlobalHttpState.
exit
Definition: login.php:29
saveResponse(ResponseInterface $response)
saveRequest(ServerRequestInterface $request)
__construct(ResponseSenderStrategy $senderStrategy, CookieJarFactory $cookieJarFactory, RequestFactory $requestFactory, ResponseFactory $responseFactory)
HTTPServices constructor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Provides an interface to the ILIAS HTTP services.