ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SettingsAdditional.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
28use ILIAS\Refinery\Factory as Refinery;
29
31{
32 public function __construct(
33 int $test_id,
34 protected bool $skills_service_enabled = false,
35 protected bool $hide_info_tab = false,
36 ) {
38 }
39
44 public function toForm(
46 FieldFactory $f,
48 ?array $environment = null
49 ): array {
50 $inputs = [];
51 if ((new \ilSkillManagementSettings())->isActivated()) {
52 $inputs['skills_service_activation'] = $this->getInputSkillsServiceActivation(
53 $lng,
54 $f,
55 $environment['participant_data_exists']
56 );
57 }
58
59 $inputs['hide_info_tab'] = $f->checkbox(
60 $lng->txt('tst_hide_info_tab'),
61 $lng->txt('tst_hide_info_tab_desc')
62 )->withValue($this->getHideInfoTab());
63
64 return $inputs;
65 }
66
69 FieldFactory $f,
70 bool $participant_data_exists
71 ): Checkbox {
72 $skills_service_activation = $f->checkbox(
73 $lng->txt('tst_activate_skill_service'),
74 $lng->txt('tst_activate_skill_service_desc')
75 )->withValue($this->getSkillsServiceEnabled());
76
77 if ($participant_data_exists) {
78 return $skills_service_activation->withDisabled(true);
79 }
80
81 return $skills_service_activation;
82 }
83
84 public function toStorage(): array
85 {
86 return [
87 'skill_service' => ['integer', (int) $this->getSkillsServiceEnabled()],
88 'hide_info_tab' => ['integer', (int) $this->getHideInfoTab()],
89 ];
90 }
91
92 public function toLog(AdditionalInformationGenerator $additional_info): array
93 {
94 return [
95 AdditionalInformationGenerator::KEY_TEST_TAXONOMIES_ENABLED => $additional_info
96 ->getEnabledDisabledTagForBool($this->getSkillsServiceEnabled()),
97 AdditionalInformationGenerator::KEY_TEST_HIDE_INFO_TAB => $additional_info
98 ->getEnabledDisabledTagForBool($this->getHideInfoTab()),
99 ];
100 }
101
102 public function getSkillsServiceEnabled(): bool
103 {
104 return $this->skills_service_enabled;
105 }
106
107 public function withSkillsServiceEnabled(bool $skills_service_enabled): self
108 {
109 $clone = clone $this;
110 $clone->skills_service_enabled = $skills_service_enabled;
111 return $clone;
112 }
113
114 public function getHideInfoTab(): bool
115 {
116 return $this->hide_info_tab;
117 }
118 public function withHideInfoTab(bool $hide_info_tab): self
119 {
120 $clone = clone $this;
121 $clone->hide_info_tab = $hide_info_tab;
122 return $clone;
123 }
124}
Builds data types.
Definition: Factory.php:36
getInputSkillsServiceActivation(\ilLanguage $lng, FieldFactory $f, bool $participant_data_exists)
toLog(AdditionalInformationGenerator $additional_info)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
__construct(int $test_id, protected bool $skills_service_enabled=false, protected bool $hide_info_tab=false,)
language handling
This describes checkbox inputs.
Definition: Checkbox.php:29
This is what a factory for input fields looks like.
Definition: Factory.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
global $lng
Definition: privfeed.php:31