ILIAS  release_7 Revision v7.30-3-g800a261c036
class.Response.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
6 
11 class Response
12 {
16  protected $data = [];
17 
21  protected $http;
22 
26  public function __construct($data)
27  {
28  global $DIC;
29 
30  $this->http = $DIC->http();
31  $this->data = $data;
32  }
33 
39  public function send()
40  {
42 
43  $string = json_encode($this->data);
45  $http->saveResponse($http
46  ->response()
47  ->withAddedHeader('Content-Type', 'application/json')
48  ->withBody($stream));
49  $http->sendResponse();
50  $http->close();
51  }
52 }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: goto.php:24
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:25