ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
class.SettingsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ILIAS\UI\Factory as UIFactory;
25use ILIAS\UI\Renderer as UIRenderer;
28use Psr\Http\Message\ServerRequestInterface;
29
31{
33
34 public function __construct(
35 private readonly \ilCtrl $ctrl,
36 private readonly Language $lng,
37 private readonly UIFactory $ui_factory,
38 private readonly UIRenderer $ui_renderer,
40 private readonly ServerRequestInterface $request,
41 private readonly Refinery $refinery,
42 private readonly Repository $prompt_repository
43 ) {
44 $this->prompt_settings = $this->prompt_repository->getSettings();
45 }
46
47 public function executeCommand(): void
48 {
49 $next_class = $this->ctrl->getNextClass($this);
50 $cmd = $this->ctrl->getCmd("show");
51
52 switch ($next_class) {
53 default:
54 if (in_array($cmd, ["show", "save"])) {
55 $this->$cmd();
56 }
57 }
58 }
59
60 public function show(): void
61 {
62 $this->tpl->setContent(
63 $this->ui_renderer->render(
64 $this->buildForm()
65 )
66 );
67 }
68
69 public function save(): void
70 {
71 $form = $this->buildForm()->withRequest($this->request);
72 $data = $form->getData();
73 if ($data === null) {
74 $this->tpl->setContent(
75 $this->ui_renderer->render($form)
76 );
77 return;
78 }
79
80 $this->prompt_settings = $this->prompt_settings->withFormData($data);
81 $this->prompt_repository->saveSettings($this->prompt_settings);
82
83 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'));
84 $this->show();
85 }
86
87 private function buildForm(): StandardForm
88 {
89 return $this->ui_factory->input()->container()->form()->standard(
90 $this->ctrl->getFormActionByClass(self::class, 'save'),
91 $this->prompt_settings->toForm($this->ui_factory, $this->lng, $this->refinery)
92 );
93 }
94}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
__construct(private readonly \ilCtrl $ctrl, private readonly Language $lng, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private \ilGlobalTemplateInterface $tpl, private readonly ServerRequestInterface $request, private readonly Refinery $refinery, private readonly Repository $prompt_repository)
Profile prompt settings.
Definition: Settings.php:33
Class ilCtrl provides processing control methods.
This describes a standard form.
Definition: Standard.php:30
An entity that renders components to a string output.
Definition: Renderer.php:31
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39
readonly ilGlobalTemplateInterface $tpl
global $lng
Definition: privfeed.php:26
$data
Definition: storeScorm.php:45