ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.SettingsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
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 }
__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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $lng
Definition: privfeed.php:31