ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
GetStatus.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\Data\Factory as DataFactory;
28use ILIAS\UI\Component\Input\Factory as InputFactory;
30
41{
42 public function __construct(
43 private readonly DataFactory $data = new DataFactory(),
44 ) {
45 }
46
48 {
49 return $this->data->text()->markdown()->simpleDocument(
50 "Reports the status of the installation.\n\n"
51 . "Not available yet: nobody is allowed to perform it."
52 );
53 }
54
55 public function getInputDescription(FieldFactory $f): FormInput
56 {
57 return $f->section([], 'Get the status of the installation');
58 }
59
61 {
62 return $f->object(
63 $this->data->text()->markdown()->simpleDocument('The status of the installation.'),
64 []
65 );
66 }
67
72 public function isAllowedToPerform(int $usr_id, mixed $parameters): bool
73 {
74 return false;
75 }
76
77 public function perform(mixed $parameters): mixed
78 {
79 throw new \LogicException('The status of the installation is not available yet.');
80 }
81
85 public function maybePerformAs(InputFactory $input_factory, int $usr_id, array $raw_parameters): Result
86 {
87 if (!$this->isAllowedToPerform($usr_id, $raw_parameters)) {
88 return $this->data->error(
89 new \DomainException('You are not allowed to get the status of the installation.', 403)
90 );
91 }
92
93 try {
94 return $this->data->ok($this->perform($raw_parameters));
95 } catch (\Exception $e) {
96 return $this->data->error($e);
97 }
98 }
99}
Basic class for Queries.
Definition: Query.php:27
This describes some datastructure in terms of standard data structures such as primitives,...
Definition: Description.php:33
Builds data types.
Definition: Factory.php:36
This is a stub: the status of the installation is not collected yet.
Definition: GetStatus.php:41
isAllowedToPerform(int $usr_id, mixed $parameters)
Nobody, until there is something to report and a check for administrators to guard it.
Definition: GetStatus.php:72
getOutputDescription(Description\Factory $f)
Definition: GetStatus.php:60
perform(mixed $parameters)
This shall perform the activity.
Definition: GetStatus.php:77
__construct(private readonly DataFactory $data=new DataFactory(),)
Definition: GetStatus.php:42
getInputDescription(FieldFactory $f)
Definition: GetStatus.php:55
maybePerformAs(InputFactory $input_factory, int $usr_id, array $raw_parameters)
Definition: GetStatus.php:85
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
error()
Get the encapsulated error.
This describes inputs that can be used in forms.
Definition: FormInput.php:33
This is how a factory for inputs looks like.
Definition: Factory.php:27
This is what a factory for input fields looks like.
Definition: Factory.php:31
$data
Definition: storeScorm.php:45