ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
HTTPServices.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
3 
4 namespace ILIAS\DI;
5 
14 
20 class HTTPServices implements GlobalHttpState
21 {
22 
26  private $sender;
34  private $requestFactory;
42  private $request;
46  private $response;
47 
48 
58  {
59  $this->sender = $senderStrategy;
60  $this->cookieJarFactory = $cookieJarFactory;
61 
62  $this->requestFactory = $requestFactory;
63  $this->responseFactory = $responseFactory;
64  }
65 
66 
70  public function cookieJar() : CookieJar
71  {
72  return $this->cookieJarFactory->fromResponse($this->response());
73  }
74 
75 
79  public function request() : \Psr\Http\Message\RequestInterface
80  {
81  if ($this->request === null) {
82  $this->request = $this->requestFactory->create();
83  }
84 
85  return $this->request;
86  }
87 
88 
92  public function response() : ResponseInterface
93  {
94  if ($this->response === null) {
95  $this->response = $this->responseFactory->create();
96  }
97 
98  return $this->response;
99  }
100 
101 
105  public function saveRequest(ServerRequestInterface $request) : void
106  {
107  $this->request = $request;
108  }
109 
110 
114  public function saveResponse(ResponseInterface $response) : void
115  {
116  $this->response = $response;
117  }
118 
119 
123  public function sendResponse() : void
124  {
125  $this->sender->sendResponse($this->response());
126  }
127 
128 
129  public function close() : void
130  {
131  exit;
132  }
133 }
Interface GlobalHttpState.
exit
Definition: login.php:29
saveResponse(ResponseInterface $response)
saveRequest(ServerRequestInterface $request)
__construct(ResponseSenderStrategy $senderStrategy, CookieJarFactory $cookieJarFactory, RequestFactory $requestFactory, ResponseFactory $responseFactory)
HTTPServices constructor.
Class HTTPServicesTest.
Provides an interface to the ILIAS HTTP services.