ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\News\Common\HttpService Class Reference
+ Collaboration diagram for ILIAS\News\Common\HttpService:

Public Member Functions

 __construct (private readonly IliasHttpServices $http, private readonly Refinery $refinery)
 
 getRequest ()
 
 getRefId ()
 
 resolveRowParameter (string $key)
 
 resolveRowParameters (string $key)
 
 get (string $key, Transformation $t)
 
 sendAsync (mixed $response)
 
 has (string $key)
 

Data Fields

const string KEY_REF_ID = 'ref_id'
 
const string ALL_OBJECTS = 'ALL_OBJECTS'
 

Detailed Description

Definition at line 30 of file HttpService.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\News\Common\HttpService::__construct ( private readonly IliasHttpServices  $http,
private readonly Refinery  $refinery 
)

Definition at line 36 of file HttpService.php.

39 {
40 }

Member Function Documentation

◆ get()

ILIAS\News\Common\HttpService::get ( string  $key,
Transformation  $t 
)

Definition at line 75 of file HttpService.php.

75 : mixed
76 {
77 $wrapper = $this->http->wrapper();
78
79 return match(true) {
80 $wrapper->post()->has($key) => $wrapper->post()->retrieve($key, $t),
81 $wrapper->query()->has($key) => $wrapper->query()->retrieve($key, $t),
82 default => null,
83 };
84 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getRefId()

ILIAS\News\Common\HttpService::getRefId ( )

Definition at line 47 of file HttpService.php.

47 : int
48 {
49 return $this->get(self::KEY_REF_ID, $this->refinery->kindlyTo()->int());
50 }

References ILIAS\News\Common\HttpService\KEY_REF_ID, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getRequest()

ILIAS\News\Common\HttpService::getRequest ( )

Definition at line 42 of file HttpService.php.

42 : ServerRequestInterface
43 {
44 return $this->http->request();
45 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ has()

ILIAS\News\Common\HttpService::has ( string  $key)

Definition at line 102 of file HttpService.php.

102 : bool
103 {
104 return $this->http->wrapper()->query()->has($key) || $this->http->wrapper()->post()->has($key);
105 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ resolveRowParameter()

ILIAS\News\Common\HttpService::resolveRowParameter ( string  $key)

Definition at line 52 of file HttpService.php.

52 : string|int
53 {
54 return $this->get(
55 $key,
56 $this->refinery->byTrying(
57 [
58 $this->refinery->kindlyTo()->int(),
59 $this->refinery->kindlyTo()->string(),
60 $this->refinery->custom()->transformation(static fn(array $value): string|int => $value[0])
61 ]
62 )
63 );
64 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ resolveRowParameters()

ILIAS\News\Common\HttpService::resolveRowParameters ( string  $key)

Definition at line 66 of file HttpService.php.

66 : array|string
67 {
68 return $this->get($key, $this->refinery->custom()->transformation(
69 static fn(array|string $value): array|string => $value === self::ALL_OBJECTS || $value[0] === self::ALL_OBJECTS
70 ? self::ALL_OBJECTS
71 : array_map('intval', $value)
72 )) ?? [];
73 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ sendAsync()

ILIAS\News\Common\HttpService::sendAsync ( mixed  $response)
Parameters
Stream | string | mixed$response

Definition at line 89 of file HttpService.php.

89 : void
90 {
91 $response = match(true) {
94 default => $response,
95 };
96
97 $this->http->saveResponse($this->http->response()->withBody($response));
98 $this->http->sendResponse();
99 $this->http->close();
100 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64
$response
Definition: xapitoken.php:92

References $response, ILIAS\FileDelivery\http(), ILIAS\Filesystem\Stream\Streams\ofResource(), and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

Field Documentation

◆ ALL_OBJECTS

const string ILIAS\News\Common\HttpService::ALL_OBJECTS = 'ALL_OBJECTS'

Definition at line 34 of file HttpService.php.

◆ KEY_REF_ID

const string ILIAS\News\Common\HttpService::KEY_REF_ID = 'ref_id'

Definition at line 32 of file HttpService.php.

Referenced by ILIAS\News\Common\HttpService\getRefId().


The documentation for this class was generated from the following file: