ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLoggingConfigStoredObjective Class Reference
+ Inheritance diagram for ilLoggingConfigStoredObjective:
+ Collaboration diagram for ilLoggingConfigStoredObjective:

Public Member Functions

 __construct (Config $config)
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 
 isApplicable (Environment $environment)
 

Protected Attributes

Config $config
 

Detailed Description

Definition at line 13 of file class.ilLoggingConfigStoredObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilLoggingConfigStoredObjective::__construct ( Config  $config)

Definition at line 17 of file class.ilLoggingConfigStoredObjective.php.

References $config.

18  {
19  $this->config = $config;
20  }

Member Function Documentation

◆ achieve()

ilLoggingConfigStoredObjective::achieve ( Environment  $environment)

Objectives can be achieved.

They might add resources to the environment when they have been achieved.

This method needs to be idempotent for a given environment. That means: if this is executed a second time, nothing new should happen. Or the other way round: if the environment already looks like desired, the objective should not take any further actions when this is called.

Exceptions

Implements ILIAS\Setup\Objective.

Definition at line 44 of file class.ilLoggingConfigStoredObjective.php.

References $ini, and ILIAS\Setup\Environment\getResource().

44  : Environment
45  {
46  $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
47 
48  $logPath = '';
49  $logFile = '';
50  if ($this->config->getPathToLogfile()) {
51  $logPath = dirname($this->config->getPathToLogfile());
52  $logFile = basename($this->config->getPathToLogfile());
53  }
54 
55  $ini->setVariable("log", "enabled", $this->config->isEnabled() ? "1" : "0");
56  $ini->setVariable("log", "path", $logPath);
57  $ini->setVariable("log", "file", $logFile);
58  $ini->setVariable(
59  "log",
60  "error_path",
61  $this->config->getErrorlogDir() ?? ''
62  );
63 
64  if (!$ini->write()) {
65  throw new UnachievableException("Could not write ilias.ini.php");
66  }
67 
68  return $environment;
69  }
Signals that some goal won't be achievable by actions of the system ever.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
$ini
Definition: raiseError.php:4
+ Here is the call graph for this function:

◆ getHash()

ilLoggingConfigStoredObjective::getHash ( )

Get a hash for this objective.

The hash of two objectives must be the same, if they are the same objective, with the same config on the same environment, i.e. if the one is achieved the other is achieved as well because they are the same.

Implements ILIAS\Setup\Objective.

Definition at line 22 of file class.ilLoggingConfigStoredObjective.php.

22  : string
23  {
24  return hash("sha256", self::class);
25  }

◆ getLabel()

ilLoggingConfigStoredObjective::getLabel ( )

Get a label that describes this objective.

Implements ILIAS\Setup\Objective.

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

27  : string
28  {
29  return "Fill ini with settings for Services/Logging";
30  }

◆ getPreconditions()

ilLoggingConfigStoredObjective::getPreconditions ( Environment  $environment)

Objectives might depend on other objectives.

Exceptions
UnachievableExceptionif the objective is not achievable
Returns
Objective[]

Implements ILIAS\Setup\Objective.

Definition at line 37 of file class.ilLoggingConfigStoredObjective.php.

37  : array
38  {
39  return [
41  ];
42  }

◆ isApplicable()

ilLoggingConfigStoredObjective::isApplicable ( Environment  $environment)

Implements ILIAS\Setup\Objective.

Definition at line 74 of file class.ilLoggingConfigStoredObjective.php.

References ILIAS\LTI\ToolProvider\$enabled, $ini, and ILIAS\Setup\Environment\getResource().

74  : bool
75  {
76  $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
77  $enabled = $this->config->isEnabled() ? "1" : "0";
78 
79  $logPath = '';
80  $logFile = '';
81  if ($this->config->getPathToLogfile()) {
82  $logPath = dirname($this->config->getPathToLogfile());
83  $logFile = basename($this->config->getPathToLogfile());
84  }
85 
86  return
87  $ini->readVariable("log", "path") !== $logPath ||
88  $ini->readVariable("log", "file") !== $logFile ||
89  $ini->readVariable("log", "error_path") !== $this->config->getErrorlogDir() ||
90  $ini->readVariable("log", "enabled") !== $enabled
91  ;
92  }
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
$ini
Definition: raiseError.php:4
+ Here is the call graph for this function:

◆ isNotable()

ilLoggingConfigStoredObjective::isNotable ( )

Get to know if this is an interesting objective for a human.

Implements ILIAS\Setup\Objective.

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

32  : bool
33  {
34  return false;
35  }

Field Documentation

◆ $config

Config ilLoggingConfigStoredObjective::$config
protected

Definition at line 15 of file class.ilLoggingConfigStoredObjective.php.

Referenced by __construct().


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