ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilBadgeGUIRequest Class Reference
+ Collaboration diagram for ilBadgeGUIRequest:

Public Member Functions

 __construct (HTTP\Services $http, Refinery\Factory $refinery)
 
 getBadgeIds ()
 
 getBadgeId ()
 
 getId ()
 
 getIds ()
 
 getType ()
 
 getTgt ()
 
 getTemplateId ()
 
 getParentId ()
 

Protected Member Functions

 initRequest (HTTP\Services $http, Refinery\Factory $refinery)
 
 str (string $key)
 
 int (string $key)
 
 intArray (string $key)
 
 strArray ($key)
 
 isArray (string $key)
 Check if parameter is an array. More...
 
 get (string $key, Refinery\Transformation $t)
 

Protected Attributes

HTTP Services $http
 
Refinery Factory $refinery
 

Detailed Description

Definition at line 22 of file class.ilBadgeGUIRequest.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadgeGUIRequest::__construct ( HTTP\Services  $http,
Refinery\Factory  $refinery 
)

Definition at line 27 of file class.ilBadgeGUIRequest.php.

References initRequest().

30  {
31  $this->initRequest(
32  $http,
33  $refinery
34  );
35  }
Refinery Factory $refinery
initRequest(HTTP\Services $http, Refinery\Factory $refinery)
+ Here is the call graph for this function:

Member Function Documentation

◆ get()

ilBadgeGUIRequest::get ( string  $key,
Refinery\Transformation  $t 
)
protected
Returns
mixed|null

Definition at line 131 of file class.ilBadgeGUIRequest.php.

References ILIAS\FileDelivery\http().

132  {
133  $w = $this->http->wrapper();
134  if ($w->post()->has($key)) {
135  return $w->post()->retrieve($key, $t);
136  }
137  if ($w->query()->has($key)) {
138  return $w->query()->retrieve($key, $t);
139  }
140  return null;
141  }
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:

◆ getBadgeId()

ilBadgeGUIRequest::getBadgeId ( )

Definition at line 153 of file class.ilBadgeGUIRequest.php.

References int().

153  : int
154  {
155  return $this->int("bid");
156  }
+ Here is the call graph for this function:

◆ getBadgeIds()

ilBadgeGUIRequest::getBadgeIds ( )
Returns
int []

Definition at line 144 of file class.ilBadgeGUIRequest.php.

References int(), and intArray().

144  : array
145  {
146  $badge_ids = $this->intArray("badge_id");
147  if (count($badge_ids) === 0 && $this->int("badge_id") > 0) {
148  $badge_ids = [$this->int("badge_id")];
149  }
150  return $badge_ids;
151  }
+ Here is the call graph for this function:

◆ getId()

ilBadgeGUIRequest::getId ( )

Definition at line 158 of file class.ilBadgeGUIRequest.php.

References int().

158  : int
159  {
160  return $this->int("id");
161  }
+ Here is the call graph for this function:

◆ getIds()

ilBadgeGUIRequest::getIds ( )
Returns
string[]

Definition at line 164 of file class.ilBadgeGUIRequest.php.

References strArray().

164  : array
165  {
166  return $this->strArray("id");
167  }
+ Here is the call graph for this function:

◆ getParentId()

ilBadgeGUIRequest::getParentId ( )

Definition at line 184 of file class.ilBadgeGUIRequest.php.

References int().

184  : int
185  {
186  return $this->int("pid");
187  }
+ Here is the call graph for this function:

◆ getTemplateId()

ilBadgeGUIRequest::getTemplateId ( )

Definition at line 179 of file class.ilBadgeGUIRequest.php.

References int().

179  : int
180  {
181  return $this->int("tid");
182  }
+ Here is the call graph for this function:

◆ getTgt()

ilBadgeGUIRequest::getTgt ( )

Definition at line 174 of file class.ilBadgeGUIRequest.php.

References str().

174  : string
175  {
176  return $this->str("tgt");
177  }
+ Here is the call graph for this function:

◆ getType()

ilBadgeGUIRequest::getType ( )

Definition at line 169 of file class.ilBadgeGUIRequest.php.

References str().

169  : string
170  {
171  return $this->str("type");
172  }
+ Here is the call graph for this function:

◆ initRequest()

ilBadgeGUIRequest::initRequest ( HTTP\Services  $http,
Refinery\Factory  $refinery 
)
protected

Definition at line 37 of file class.ilBadgeGUIRequest.php.

References $http, $refinery, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by __construct().

40  : void {
41  $this->http = $http;
42  $this->refinery = $refinery;
43  }
Refinery Factory $refinery
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ int()

ilBadgeGUIRequest::int ( string  $key)
protected

Definition at line 53 of file class.ilBadgeGUIRequest.php.

References ILIAS\LTI\ToolProvider\$key, and ILIAS\Repository\refinery().

Referenced by getBadgeId(), getBadgeIds(), getId(), getParentId(), getTemplateId(), and intArray().

53  : int
54  {
55  $t = $this->refinery->kindlyTo()->int();
56  return (int) ($this->get($key, $t) ?? 0);
57  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ intArray()

ilBadgeGUIRequest::intArray ( string  $key)
protected

Definition at line 60 of file class.ilBadgeGUIRequest.php.

References ILIAS\LTI\ToolProvider\$key, int(), isArray(), and ILIAS\Repository\refinery().

Referenced by getBadgeIds().

60  : array
61  {
62  if (!$this->isArray($key)) {
63  return [];
64  }
65  $t = $this->refinery->custom()->transformation(
66  static function (array $arr): array {
67  // keep keys(!), transform all values to int
68  return array_column(
69  array_map(
70  static function ($k, $v): array {
71  return [$k, (int) $v];
72  },
73  array_keys($arr),
74  $arr
75  ),
76  1,
77  0
78  );
79  }
80  );
81  return (array) ($this->get($key, $t) ?? []);
82  }
isArray(string $key)
Check if parameter is an array.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isArray()

ilBadgeGUIRequest::isArray ( string  $key)
protected

Check if parameter is an array.

Definition at line 115 of file class.ilBadgeGUIRequest.php.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by intArray(), and strArray().

115  : bool
116  {
117  $no_transform = $this->refinery->identity();
118  $w = $this->http->wrapper();
119  if ($w->post()->has($key)) {
120  return is_array($w->post()->retrieve($key, $no_transform));
121  }
122  if ($w->query()->has($key)) {
123  return is_array($w->query()->retrieve($key, $no_transform));
124  }
125  return false;
126  }
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ str()

ilBadgeGUIRequest::str ( string  $key)
protected

Definition at line 46 of file class.ilBadgeGUIRequest.php.

References ILIAS\Repository\refinery().

Referenced by getTgt(), and getType().

46  : string
47  {
48  $t = $this->refinery->kindlyTo()->string();
49  return \ilUtil::stripSlashes((string) ($this->get($key, $t) ?? ""));
50  }
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ strArray()

ilBadgeGUIRequest::strArray (   $key)
protected

Definition at line 85 of file class.ilBadgeGUIRequest.php.

References ILIAS\LTI\ToolProvider\$key, isArray(), ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

Referenced by getIds().

85  : array
86  {
87  if (!$this->isArray($key)) {
88  return [];
89  }
90  $t = $this->refinery->custom()->transformation(
91  function ($arr) {
92  // keep keys(!), transform all values to string
93  return array_column(
94  array_map(
95  function ($k, $v) {
96  if (is_array($v)) {
97  $v = "";
98  }
99  return [$k, \ilUtil::stripSlashes((string) $v)];
100  },
101  array_keys($arr),
102  $arr
103  ),
104  1,
105  0
106  );
107  }
108  );
109  return (array) ($this->get($key, $t) ?? []);
110  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
isArray(string $key)
Check if parameter is an array.
string $key
Consumer key/client ID value.
Definition: System.php:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $http

HTTP Services ilBadgeGUIRequest::$http
protected

Definition at line 24 of file class.ilBadgeGUIRequest.php.

Referenced by initRequest().

◆ $refinery

Refinery Factory ilBadgeGUIRequest::$refinery
protected

Definition at line 25 of file class.ilBadgeGUIRequest.php.

Referenced by initRequest().


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