ILIAS  release_8 Revision v8.24
class.InternalRequestService.php
Go to the documentation of this file.
1<?php
2
20
22
24{
26
27 protected \ILIAS\HTTP\Services $http;
28 protected \ILIAS\FileUpload\FileUpload $upload;
29
30 public function __construct(
31 \ILIAS\HTTP\Services $http,
32 \ILIAS\Refinery\Factory $refinery,
33 \ILIAS\FileUpload\FileUpload $upload
34 ) {
35 $this->initRequest(
36 $http,
38 );
39 $this->upload = $upload;
40 }
41
45 public function getProcessedUploads(): array
46 {
47 $uploads = [];
48 if ($this->upload->hasUploads()) {
49 if (!$this->upload->hasBeenProcessed()) {
50 $this->upload->process();
51 }
52 $uploads = $this->upload->getResults();
53 }
54
55 return $uploads;
56 }
57
63 public function getUploadFilename(array $http_names, int $index): ?string
64 {
65 $uploaded_files = $this->http->request()->getUploadedFiles();
66
67 while (($current_key = array_shift($http_names)) !== null) {
68 if (!isset($uploaded_files[$current_key])) {
69 return null;
70 }
71
72 $uploaded_files = $uploaded_files[$current_key];
73
74 if (isset($uploaded_files[$index]) && $http_names === []) {
76 $file = $uploaded_files[$index];
77 $c = \Closure::bind(static function (\GuzzleHttp\Psr7\UploadedFile $file): ?string {
78 return $file->file ?? null;
79 }, null, $file);
80
81 return $c($file);
82 }
83 }
84
85 return null;
86 }
87
88 public function upload(): \ILIAS\FileUpload\FileUpload
89 {
90 return $this->upload;
91 }
92
93 public function isset(string $key): bool
94 {
95 return $this->raw($key) !== null;
96 }
97 public function hasRefId(): int
98 {
99 return $this->raw('ref_id') !== null;
100 }
101
102 public function getRefId(): int
103 {
104 return $this->int("ref_id");
105 }
106
107 public function hasQuestionId(): bool
108 {
109 return $this->raw('q_id') !== null;
110 }
111
112 public function getQuestionId(): int
113 {
114 return $this->int('q_id');
115 }
116
118 public function getIds(): array
119 {
120 return $this->strArray("id");
121 }
122
126 public function raw(string $key)
127 {
128 $no_transform = $this->refinery->identity();
129 return $this->get($key, $no_transform);
130 }
131
132 public function getParsedBody()
133 {
134 return $this->http->request()->getParsedBody();
135 }
136
140 public function getUnitIds(): array
141 {
142 return $this->intArray("unit_ids");
143 }
144
148 public function getUnitCategoryIds(): array
149 {
150 return $this->intArray("category_ids");
151 }
152}
__construct(\ILIAS\HTTP\Services $http, \ILIAS\Refinery\Factory $refinery, \ILIAS\FileUpload\FileUpload $upload)
$c
Definition: cli.php:38
$index
Definition: metadata.php:145
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193
Refinery Factory $refinery
trait BaseGUIRequest
Base gui request wrapper.
initRequest(HTTP\Services $http, Refinery\Factory $refinery, ?array $passed_query_params=null, ?array $passed_post_data=null)
Query params and post data parameters are used for testing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider \MainMenu\Provider.