ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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)
 
 getBuildArtifactObjective ()
 
 getStatusObjective (Setup\Metrics\Storage $storage)
 
 getMigrations ()
 

Static Public Attributes

static array $LOG_LEVELS
 
static array $INTERVALS
 

Private Attributes

const PORT_MIN = 1
 
const PORT_MAX = 65535
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

56  {
57  }

Member Function Documentation

◆ getArrayToConfigTransformation()

ilChatroomSetupAgent::getArrayToConfigTransformation ( )

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

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

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

◆ getBuildArtifactObjective()

ilChatroomSetupAgent::getBuildArtifactObjective ( )

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

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

◆ getConfigInput()

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

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

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

◆ getInstallObjective()

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

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

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

◆ getMigrations()

ilChatroomSetupAgent::getMigrations ( )

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

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

◆ getStatusObjective()

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

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

241  : Setup\Objective
242  {
243  return new Setup\ObjectiveCollection(
244  'Component Chatroom',
245  true,
248  );
249  }

◆ getUpdateObjective()

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

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

References $objectives.

221  : Setup\Objective
222  {
223  $objectives = [
225  ];
226 
227  // null would be valid here, because our user might just not have passed
228  // one during update.
229  if ($config !== null && !($config instanceof Setup\NullConfig)) {
231  }
232 
233  return new ObjectiveCollection('Update chatroom database and server config', false, ...$objectives);
234  }
A objective collection is a objective that is achieved once all subobjectives are achieved...
$objectives
A configuration with no content.
Definition: NullConfig.php:26

◆ hasConfig()

ilChatroomSetupAgent::hasConfig ( )

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

59  : bool
60  {
61  return true;
62  }

Field Documentation

◆ $INTERVALS

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

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

◆ $LOG_LEVELS

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

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

◆ PORT_MAX

const ilChatroomSetupAgent::PORT_MAX = 65535
private

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

◆ PORT_MIN

const ilChatroomSetupAgent::PORT_MIN = 1
private

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


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