ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
SettingsIntroduction.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 $introduction_enabled = false,
34 protected ?int $introduction_page_id = null,
35 protected bool $conditions_checkbox_enabled = false,
36 ) {
38 }
39
40 public function toForm(
42 FieldFactory $f,
44 ?array $environment = null
45 ): FormInput {
46 $inputs['introduction_enabled'] = $f->checkbox(
47 $lng->txt('tst_introduction'),
48 $lng->txt('tst_introduction_desc')
50
51 $inputs['conditions_checkbox_enabled'] = $f->checkbox(
52 $lng->txt('tst_conditions_checkbox_enabled'),
53 $lng->txt('tst_conditions_checkbox_enabled_desc')
54 )->withValue($this->getExamConditionsCheckboxEnabled());
55
56 return $f->section($inputs, $lng->txt('tst_settings_header_intro'));
57 }
58
59 public function toStorage(): array
60 {
61 return [
62 'intro_enabled' => ['integer', (int) $this->getIntroductionEnabled()],
63 'introduction_page_id' => ['integer', $this->getIntroductionPageId()],
64 'conditions_checkbox_enabled' => ['integer', (int) $this->getExamConditionsCheckboxEnabled()],
65 ];
66 }
67
68 public function toLog(AdditionalInformationGenerator $additional_info): array
69 {
70 return [
72 ->getEnabledDisabledTagForBool($this->getIntroductionEnabled()),
74 ->getEnabledDisabledTagForBool($this->getExamConditionsCheckboxEnabled()),
75 ];
76 }
77
78 public function getIntroductionEnabled(): bool
79 {
80 return $this->introduction_enabled;
81 }
82
83 public function withIntroductionEnabled(bool $introduction_enabled): self
84 {
85 $clone = clone $this;
86 $clone->introduction_enabled = $introduction_enabled;
87 return $clone;
88 }
89
90 public function getIntroductionPageId(): ?int
91 {
92 return $this->introduction_page_id;
93 }
94 public function withIntroductionPageId(?int $introduction_page_id): self
95 {
96 $clone = clone $this;
97 $clone->introduction_page_id = $introduction_page_id;
98 return $clone;
99 }
100
101 public function getExamConditionsCheckboxEnabled(): bool
102 {
103 return $this->conditions_checkbox_enabled;
104 }
105 public function withExamConditionsCheckboxEnabled(bool $conditions_checkbox_enabled): self
106 {
107 $clone = clone $this;
108 $clone->conditions_checkbox_enabled = $conditions_checkbox_enabled;
109 return $clone;
110 }
111
112 public function toExport(): array
113 {
114 return [
115 'intro_enabled' => $this->getIntroductionEnabled(),
116 'introduction_page_id' => $this->getIntroductionPageId(),
117 'conditions_checkbox_enabled' => $this->getExamConditionsCheckboxEnabled()
118 ];
119 }
120
121 public static function fromExport(array $data): static
122 {
123 return new self(
124 (bool) $data['intro_enabled'],
125 $data['introduction_page_id'],
126 (bool) $data['conditions_checkbox_enabled'],
127 );
128 }
129}
Builds data types.
Definition: Factory.php:36
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
toExport()
Transform the object into a simple, associative array.
withExamConditionsCheckboxEnabled(bool $conditions_checkbox_enabled)
static fromExport(array $data)
Creates an instance of the object from an array.
__construct(protected bool $introduction_enabled=false, protected ?int $introduction_page_id=null, protected bool $conditions_checkbox_enabled=false,)
toLog(AdditionalInformationGenerator $additional_info)
language handling
This interface allows an object to define its own transformation into a language-neutral,...
Definition: Exportable.php:40
This describes inputs that can be used in forms.
Definition: FormInput.php:33
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