ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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;
28
29use Psr\Http\Message\ServerRequestInterface;
30
32{
34
35 public function __construct(
36 private readonly \ilCtrl $ctrl,
37 private readonly Language $lng,
38 private readonly UIFactory $ui_factory,
39 private readonly UIRenderer $ui_renderer,
40 private \ilGlobalTemplateInterface $tpl,
41 private readonly ServerRequestInterface $request,
42 private readonly Refinery $refinery,
43 private readonly Repository $prompt_repository
44 ) {
45 $this->prompt_settings = $this->prompt_repository->getSettings();
46 }
47
48 public function executeCommand(): void
49 {
50 $next_class = $this->ctrl->getNextClass($this);
51 $cmd = $this->ctrl->getCmd("show");
52
53 switch ($next_class) {
54 default:
55 if (in_array($cmd, ["show", "save"])) {
56 $this->$cmd();
57 }
58 }
59 }
60
61 public function show(): void
62 {
63 $this->tpl->setContent(
64 $this->ui_renderer->render(
65 $this->buildForm()
66 )
67 );
68 }
69
70 public function save(): void
71 {
72 $form = $this->buildForm()->withRequest($this->request);
73 $data = $form->getData();
74 if ($data === null) {
75 $this->tpl->setContent(
76 $this->ui_renderer->render($form)
77 );
78 return;
79 }
80
81 $this->prompt_settings = $this->prompt_settings->withFormData($data);
82 $this->prompt_repository->saveSettings($this->prompt_settings);
83
84 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'));
85 $this->show();
86 }
87
88 private function buildForm(): StandardForm
89 {
90 return $this->ui_factory->input()->container()->form()->standard(
91 $this->ctrl->getFormActionByClass(self::class, 'save'),
92 $this->prompt_settings->toForm($this->ui_factory, $this->lng, $this->refinery)
93 );
94 }
95}
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:29
An entity that renders components to a string output.
Definition: Renderer.php:31
global $lng
Definition: privfeed.php:31