ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilForumNotificationEventsFormGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
24  private array $events = [
25  'notify_modified' => ilForumNotificationEvents::UPDATED,
26  'notify_censored' => ilForumNotificationEvents::CENSORED,
27  'notify_uncensored' => ilForumNotificationEvents::UNCENSORED,
28  'notify_post_deleted' => ilForumNotificationEvents::POST_DELETED,
29  'notify_thread_deleted' => ilForumNotificationEvents::THREAD_DELETED,
30  ];
31 
32  public function __construct(
33  private readonly string $action,
34  private ?array $predefined_values,
35  private readonly \ILIAS\UI\Factory $ui_factory,
36  private readonly ilLanguage $lng
37  ) {
38  }
39 
40  public function getValueForEvent(string $event): int
41  {
42  if (isset($this->events[$event])) {
43  return $this->events[$event];
44  }
45 
46  throw new InvalidArgumentException(sprintf('Event "%s" is not supported.', $event));
47  }
48 
52  public function getValidEvents(): array
53  {
54  return array_keys($this->events);
55  }
56 
57  public function build(): \ILIAS\UI\Component\Input\Container\Form\Form
58  {
59  $items = [];
60 
61  foreach (array_keys($this->events) as $key) {
62  $checkbox = $this->ui_factory->input()->field()->checkbox($this->lng->txt($key));
63  if ($this->predefined_values !== null && isset($this->predefined_values[$key])) {
64  $checkbox = $checkbox->withValue($this->predefined_values[$key]);
65  }
66 
67  $items[$key] = $checkbox;
68  }
69 
70  $hidden = $this->ui_factory->input()->field()->hidden();
71  if ($this->predefined_values !== null && isset($this->predefined_values['hidden_value'])) {
72  $hidden = $hidden->withValue((string) $this->predefined_values['hidden_value']);
73  }
74  $items['hidden_value'] = $hidden;
75 
76  return $this->ui_factory->input()->container()->form()->standard(
77  $this->action,
78  $items
79  );
80  }
81 }
array __construct(private readonly string $action, private ?array $predefined_values, private readonly \ILIAS\UI\Factory $ui_factory, private readonly ilLanguage $lng)
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $lng
Definition: privfeed.php:31