ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChatroomSetupAgent Class Reference
+ Inheritance diagram for ilChatroomSetupAgent:
+ Collaboration diagram for ilChatroomSetupAgent:

Public Member Functions

 __construct (protected Refinery\Factory $refinery)
 
 hasConfig ()
 
 getConfigInput (?Setup\Config $config=null)
 
 getArrayToConfigTransformation ()
 
 getInstallObjective (?Setup\Config $config=null)
 
 getUpdateObjective (?Setup\Config $config=null)
 
 getBuildObjective ()
 
 getStatusObjective (Setup\Metrics\Storage $storage)
 
 getMigrations ()
 

Static Public Attributes

static array $LOG_LEVELS
 
static array $INTERVALS
 

Private Attributes

const int PORT_MIN = 1
 
const int PORT_MAX = 65535
 

Detailed Description

Definition at line 26 of file class.ilChatroomSetupAgent.php.

Constructor & Destructor Documentation

◆ __construct()

ilChatroomSetupAgent::__construct ( protected Refinery\Factory  $refinery)

Definition at line 54 of file class.ilChatroomSetupAgent.php.

55 {
56 }

Member Function Documentation

◆ getArrayToConfigTransformation()

ilChatroomSetupAgent::getArrayToConfigTransformation ( )

Definition at line 68 of file class.ilChatroomSetupAgent.php.

68 : Refinery\Transformation
69 {
70 $levels = self::$LOG_LEVELS;
71 $intervals = self::$INTERVALS;
72
73 return $this->refinery->custom()->transformation(static function ($data) use (
74 $levels,
75 $intervals
76 ): Setup\Config {
77 if (is_null($data)) {
78 return new Setup\NullConfig();
79 }
80
81 $protocol = 'http';
82 if (isset($data['https']) && is_array($data['https']) && $data['https'] !== []) {
83 $protocol = 'https';
84 }
85
86 $deletion_interval = false;
87 if (
88 isset($data['deletion_interval']) &&
89 is_array($data['deletion_interval']) && $data['deletion_interval'] !== []
90 ) {
91 $deletion_interval = true;
92 }
93
94 $ilias_proxy = false;
95 if (isset($data['ilias_proxy']) && is_array($data['ilias_proxy']) && $data['ilias_proxy'] !== []) {
96 $ilias_proxy = true;
97 }
98
99 $client_proxy = false;
100 if (isset($data['client_proxy']) && is_array($data['client_proxy']) && $data['client_proxy'] !== []) {
101 $client_proxy = true;
102 }
103
104 if (isset($data['address']) && !is_string($data['address'])) {
105 throw new InvalidArgumentException(sprintf(
106 '%s is not a valid value for address (must be a string). Please check your config file.',
107 $data['address'],
108 ));
109 }
110
111 if (
112 isset($data['port']) && (
113 !is_numeric($data['port']) ||
114 ((int) $data['port'] < self::PORT_MIN || (int) $data['port'] > self::PORT_MAX)
115 )
116 ) {
117 throw new InvalidArgumentException(sprintf(
118 '%s is not a valid value for port (must be between %s and %s). Please check your config file.',
119 $data['port'] ?? '',
120 self::PORT_MIN,
121 self::PORT_MAX
122 ));
123 }
124
125 if (isset($data['sub_directory']) && !is_string($data['sub_directory'])) {
126 throw new InvalidArgumentException(sprintf(
127 '%s is not a valid value for sub_directory (must be a string). Please check your config file.',
128 $data['sub_directory'],
129 ));
130 }
131
132 if (isset($data['log']) && !is_string($data['log'])) {
133 throw new InvalidArgumentException(sprintf(
134 '%s is not a valid value for log (must be a string). Please check your config file.',
135 $data['log'],
136 ));
137 }
138
139 if (isset($data['error_log']) && !is_string($data['error_log'])) {
140 throw new InvalidArgumentException(sprintf(
141 '%s is not a valid value for error_log (must be a string). Please check your config file.',
142 $data['error_log'],
143 ));
144 }
145
146 if (
147 isset($data['log']) && $data['log'] !== '' &&
148 !in_array((string) ($data['log_level'] ?? ''), $levels, true)
149 ) {
150 throw new InvalidArgumentException(sprintf(
151 '%s is not a valid value for log_level (must be one of: %s). Please check your config file.',
152 $data['log_level'] ?? '',
153 implode(', ', $levels)
154 ));
155 }
156
157 if ($deletion_interval) {
158 if (!in_array($data['deletion_interval']['deletion_unit'] ?? null, $intervals, true)) {
159 throw new InvalidArgumentException(sprintf(
160 '%s is not a valid value for deletion_unit (must be one of: %s). Please check your config file.',
161 $data['deletion_interval']['deletion_unit'] ?? '',
162 implode(', ', $intervals)
163 ));
164 }
165 if (
166 !isset($data['deletion_interval']['deletion_value']) ||
167 !is_numeric($data['deletion_interval']['deletion_value'])
168 ) {
169 throw new InvalidArgumentException(sprintf(
170 '%s is not a valid value for deletion_value. Please check your config file.',
171 $data['deletion_interval']['deletion_value'] ?? ''
172 ));
173 }
174 if (
175 !isset($data['deletion_interval']['deletion_time']) ||
176 !is_string($data['deletion_interval']['deletion_time']) ||
177 !preg_match('/([01][0-9]|[2][0-3]):[0-5][0-9]/', $data['deletion_interval']['deletion_time'])
178 ) {
179 throw new InvalidArgumentException(sprintf(
180 '%s is not a valid value for deletion_time. Please check your config file.',
181 $data['deletion_interval']['deletion_time'] ?? ''
182 ));
183 }
184 }
185
186 return new ilChatroomSetupConfig(
187 $data['address'] ?? '',
188 (int) ($data['port'] ?? 0),
189 $data['sub_directory'] ?? '',
190 $protocol,
191 $data['https']['cert'] ?? '',
192 $data['https']['key'] ?? '',
193 $data['https']['dhparam'] ?? '',
194 $data['log'] ?? '',
195 $data['log_level'] ?? '',
196 $data['error_log'] ?? '',
197 $ilias_proxy,
198 $data['ilias_proxy']['ilias_url'] ?? '',
199 $client_proxy,
200 $data['client_proxy']['client_url'] ?? '',
201 $deletion_interval,
202 $data['deletion_interval']['deletion_unit'] ?? '',
203 (int) ($data['deletion_interval']['deletion_value'] ?? 0),
204 $data['deletion_interval']['deletion_time'] ?? ''
205 );
206 });
207 }
A configuration for the setup.
Definition: Config.php:27

References $data, $INTERVALS, $LOG_LEVELS, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getBuildObjective()

ilChatroomSetupAgent::getBuildObjective ( )

Definition at line 235 of file class.ilChatroomSetupAgent.php.

235 : Setup\Objective
236 {
237 return new Setup\Objective\NullObjective();
238 }

◆ getConfigInput()

ilChatroomSetupAgent::getConfigInput ( ?Setup\Config  $config = null)

Definition at line 63 of file class.ilChatroomSetupAgent.php.

63 : never
64 {
65 throw new LogicException("Not yet implemented.");
66 }

◆ getInstallObjective()

ilChatroomSetupAgent::getInstallObjective ( ?Setup\Config  $config = null)

Definition at line 209 of file class.ilChatroomSetupAgent.php.

209 : Setup\Objective
210 {
211 // null would not be valid here, because this agents strictly wants to have
212 // a config.
213 if ($config === null || $config instanceof Setup\NullConfig) {
214 return new Setup\Objective\NullObjective();
215 }
216
217 return new ilChatroomServerConfigStoredObjective($config);
218 }
A configuration with no content.
Definition: NullConfig.php:27

◆ getMigrations()

ilChatroomSetupAgent::getMigrations ( )

Definition at line 250 of file class.ilChatroomSetupAgent.php.

250 : array
251 {
252 return [];
253 }

◆ getStatusObjective()

ilChatroomSetupAgent::getStatusObjective ( Setup\Metrics\Storage  $storage)

◆ getUpdateObjective()

ilChatroomSetupAgent::getUpdateObjective ( ?Setup\Config  $config = null)

Definition at line 220 of file class.ilChatroomSetupAgent.php.

220 : Setup\Objective
221 {
222 $objectives = [
224 ];
225
226 // null would be valid here, because our user might just not have passed
227 // one during update.
228 if ($config !== null && !($config instanceof Setup\NullConfig)) {
230 }
231
232 return new ObjectiveCollection('Update chatroom database and server config', false, ...$objectives);
233 }
A objective collection is a objective that is achieved once all subobjectives are achieved.
This class attempt to achieve a set of database update steps.
$objectives

References $objectives.

◆ hasConfig()

ilChatroomSetupAgent::hasConfig ( )

Definition at line 58 of file class.ilChatroomSetupAgent.php.

58 : bool
59 {
60 return true;
61 }

Field Documentation

◆ $INTERVALS

array ilChatroomSetupAgent::$INTERVALS
static
Initial value:
= [
'days',
'weeks',
'months',
'years'
]

Definition at line 47 of file class.ilChatroomSetupAgent.php.

Referenced by getArrayToConfigTransformation().

◆ $LOG_LEVELS

array ilChatroomSetupAgent::$LOG_LEVELS
static
Initial value:
= [
'emerg',
'alert',
'crit',
'error',
'warning',
'notice',
'info',
'debug',
'silly'
]

Definition at line 34 of file class.ilChatroomSetupAgent.php.

Referenced by getArrayToConfigTransformation().

◆ PORT_MAX

const int ilChatroomSetupAgent::PORT_MAX = 65535
private

Definition at line 31 of file class.ilChatroomSetupAgent.php.

◆ PORT_MIN

const int ilChatroomSetupAgent::PORT_MIN = 1
private

Definition at line 30 of file class.ilChatroomSetupAgent.php.


The documentation for this class was generated from the following file: