ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
SettingsAdditional.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ILIAS\Refinery\Factory as Refinery;
29
31{
32 public function __construct(
33 protected bool $skills_service_enabled = false,
34 protected bool $hide_info_tab = false,
35 ) {
37 }
38
43 public function toForm(
45 FieldFactory $f,
47 ?array $environment = null
48 ): array {
49 $inputs = [];
50 if ((new \ilSkillManagementSettings())->isActivated()) {
51 $inputs['skills_service_activation'] = $this->getInputSkillsServiceActivation(
52 $lng,
53 $f,
54 $environment['participant_data_exists']
55 );
56 }
57
58 $inputs['hide_info_tab'] = $f->checkbox(
59 $lng->txt('tst_hide_info_tab'),
60 $lng->txt('tst_hide_info_tab_desc')
61 )->withValue($this->getHideInfoTab());
62
63 return $inputs;
64 }
65
68 FieldFactory $f,
69 bool $participant_data_exists
70 ): Checkbox {
71 $skills_service_activation = $f->checkbox(
72 $lng->txt('tst_activate_skill_service'),
73 $lng->txt('tst_activate_skill_service_desc')
74 )->withValue($this->getSkillsServiceEnabled());
75
76 if ($participant_data_exists) {
77 return $skills_service_activation->withDisabled(true);
78 }
79
80 return $skills_service_activation;
81 }
82
83 public function toStorage(): array
84 {
85 return [
86 'skill_service' => ['integer', (int) $this->getSkillsServiceEnabled()],
87 'hide_info_tab' => ['integer', (int) $this->getHideInfoTab()],
88 ];
89 }
90
91 public function toLog(AdditionalInformationGenerator $additional_info): array
92 {
93 return [
94 AdditionalInformationGenerator::KEY_TEST_TAXONOMIES_ENABLED => $additional_info
95 ->getEnabledDisabledTagForBool($this->getSkillsServiceEnabled()),
96 AdditionalInformationGenerator::KEY_TEST_HIDE_INFO_TAB => $additional_info
97 ->getEnabledDisabledTagForBool($this->getHideInfoTab()),
98 ];
99 }
100
101 public function getSkillsServiceEnabled(): bool
102 {
103 return $this->skills_service_enabled;
104 }
105
106 public function withSkillsServiceEnabled(bool $skills_service_enabled): self
107 {
108 $clone = clone $this;
109 $clone->skills_service_enabled = $skills_service_enabled;
110 return $clone;
111 }
112
113 public function getHideInfoTab(): bool
114 {
115 return $this->hide_info_tab;
116 }
117 public function withHideInfoTab(bool $hide_info_tab): self
118 {
119 $clone = clone $this;
120 $clone->hide_info_tab = $hide_info_tab;
121 return $clone;
122 }
123
124 public function toExport(): array
125 {
126 return [
127 'skill_service' => $this->getSkillsServiceEnabled(),
128 'hide_info_tab' => $this->getHideInfoTab(),
129 ];
130 }
131
132 public static function fromExport(array $data): static
133 {
134 return new self(
135 (bool) $data['skill_service'],
136 (bool) $data['hide_info_tab'],
137 );
138 }
139}
Builds data types.
Definition: Factory.php:36
getInputSkillsServiceActivation(\ilLanguage $lng, FieldFactory $f, bool $participant_data_exists)
static fromExport(array $data)
Creates an instance of the object from an array.
toLog(AdditionalInformationGenerator $additional_info)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
toExport()
Transform the object into a simple, associative array.
__construct(protected bool $skills_service_enabled=false, protected bool $hide_info_tab=false,)
language handling
This interface allows an object to define its own transformation into a language-neutral,...
Definition: Exportable.php:40
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