ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilForumNotificationEventsFormGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  private string $action;
24  private ?array $predefined_values;
25  private \ILIAS\UI\Factory $ui_factory;
26  private ilLanguage $lng;
28  private array $events = [
29  'notify_modified' => ilForumNotificationEvents::UPDATED,
30  'notify_censored' => ilForumNotificationEvents::CENSORED,
31  'notify_uncensored' => ilForumNotificationEvents::UNCENSORED,
32  'notify_post_deleted' => ilForumNotificationEvents::POST_DELETED,
33  'notify_thread_deleted' => ilForumNotificationEvents::THREAD_DELETED,
34  ];
35 
36  public function __construct(
37  string $action,
38  ?array $predefined_values,
39  \ILIAS\UI\Factory $ui_factory,
40  ilLanguage $lng
41  ) {
42  $this->action = $action;
43  $this->predefined_values = $predefined_values;
44  $this->ui_factory = $ui_factory;
45  $this->lng = $lng;
46  }
47 
48  public function getValueForEvent(string $event): int
49  {
50  if (isset($this->events[$event])) {
51  return $this->events[$event];
52  }
53 
54  throw new InvalidArgumentException(sprintf('Event "%s" is not supported.', $event));
55  }
56 
60  public function getValidEvents(): array
61  {
62  return array_keys($this->events);
63  }
64 
65  public function build(): \ILIAS\UI\Component\Input\Container\Form\Form
66  {
67  $items = [];
68 
69  foreach ($this->events as $key => $id) {
70  $checkbox = $this->ui_factory->input()->field()->checkbox($this->lng->txt($key));
71  if ($this->predefined_values !== null && isset($this->predefined_values[$key])) {
72  $checkbox = $checkbox->withValue($this->predefined_values[$key]);
73  }
74 
75  $items[$key] = $checkbox;
76  }
77 
78  $hidden = $this->ui_factory->input()->field()->hidden();
79  if ($this->predefined_values !== null && isset($this->predefined_values['hidden_value'])) {
80  $hidden = $hidden->withValue((string) $this->predefined_values['hidden_value']);
81  }
82  $items['hidden_value'] = $hidden;
83 
84  return $this->ui_factory->input()->container()->form()->standard(
85  $this->action,
86  $items
87  );
88  }
89 }
Class Factory.
Class ChatMainBarProvider .
array __construct(string $action, ?array $predefined_values, \ILIAS\UI\Factory $ui_factory, ilLanguage $lng)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23