ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.Response.php
Go to the documentation of this file.
1 <?php
2 
20 
24 class Response
25 {
29  protected $data = [];
30 
31  protected \ILIAS\HTTP\Services $http;
32 
36  public function __construct($data)
37  {
38  global $DIC;
39 
40  $this->http = $DIC->http();
41  $this->data = $data;
42  }
43 
44  public function send(): void
45  {
46  $http = $this->http;
47 
48  $string = json_encode($this->data);
50  $http->saveResponse($http
51  ->response()
52  ->withAddedHeader('Content-Type', 'application/json')
53  ->withBody($stream));
54  $http->sendResponse();
55  $http->close();
56  }
57 }
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43