ILIAS  release_8 Revision v8.24
class.ilObjectRequestRetriever.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
24
31{
33 protected Factory $refinery;
34
36 {
37 $this->wrapper = $wrapper;
38 $this->refinery = $refinery;
39 }
40
44 private function getFromRequest(string $key, Transformation $t)
45 {
46 if ($this->wrapper->query()->has($key)) {
47 return $this->wrapper->query()->retrieve($key, $t);
48 }
49 if ($this->wrapper->post()->has($key)) {
50 return $this->wrapper->post()->retrieve($key, $t);
51 }
52 return null;
53 }
54
55 public function has(string $key): bool
56 {
57 return $this->wrapper->query()->has($key)
58 || $this->wrapper->post()->has($key);
59 }
60
61 public function getMaybeInt(string $key, ?int $fallback = null): ?int
62 {
63 return $this->getFromRequest($key, $this->refinery->kindlyTo()->int()) ?? $fallback;
64 }
65
66 public function getMaybeString(string $key, ?string $fallback = null): ?string
67 {
68 return $this->getFromRequest($key, $this->refinery->kindlyTo()->string()) ?? $fallback;
69 }
70
71 public function getBool(string $key): bool
72 {
73 return $this->getFromRequest($key, $this->refinery->kindlyTo()->bool()) ?? false;
74 }
75}
Builds data types.
Definition: Factory.php:21
Base class for all sub item list gui's.
getMaybeInt(string $key, ?int $fallback=null)
getFromRequest(string $key, Transformation $t)
__construct(WrapperFactory $wrapper, Factory $refinery)
getMaybeString(string $key, ?string $fallback=null)
A transformation is a function from one datatype to another.
string $key
Consumer key/client ID value.
Definition: System.php:193