ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLoggingConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25
27{
28 protected Config $config;
29
30 public function __construct(Config $config)
31 {
32 $this->config = $config;
33 }
34
35 public function getHash(): string
36 {
37 return hash("sha256", self::class);
38 }
39
40 public function getLabel(): string
41 {
42 return "Fill ini with settings for Services/Logging";
43 }
44
45 public function isNotable(): bool
46 {
47 return false;
48 }
49
50 public function getPreconditions(Environment $environment): array
51 {
52 return [
54 ];
55 }
56
57 public function achieve(Environment $environment): Environment
58 {
59 $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
60
61 $logPath = '';
62 $logFile = '';
63 if ($this->config->getPathToLogfile()) {
64 $logPath = dirname($this->config->getPathToLogfile());
65 $logFile = basename($this->config->getPathToLogfile());
66 }
67
68 $ini->setVariable("log", "enabled", $this->config->isEnabled() ? "1" : "0");
69 $ini->setVariable("log", "path", $logPath);
70 $ini->setVariable("log", "file", $logFile);
71 $ini->setVariable(
72 "log",
73 "error_path",
74 $this->config->getErrorlogDir() ?? ''
75 );
76
77 if (!$ini->write()) {
78 throw new UnachievableException("Could not write ilias.ini.php");
79 }
80
81 return $environment;
82 }
83
87 public function isApplicable(Environment $environment): bool
88 {
89 $ini = $environment->getResource(Environment::RESOURCE_ILIAS_INI);
90 $enabled = $this->config->isEnabled() ? "1" : "0";
91
92 $logPath = '';
93 $logFile = '';
94 if ($this->config->getPathToLogfile()) {
95 $logPath = dirname($this->config->getPathToLogfile());
96 $logFile = basename($this->config->getPathToLogfile());
97 }
98
99 return
100 $ini->readVariable("log", "path") !== $logPath ||
101 $ini->readVariable("log", "file") !== $logFile ||
102 $ini->readVariable("log", "error_path") !== $this->config->getErrorlogDir() ||
103 $ini->readVariable("log", "enabled") !== $enabled
104 ;
105 }
106}
Signals that some goal won't be achievable by actions of the system ever.
isApplicable(Environment $environment)
@inheritDoc
getPreconditions(Environment $environment)
Objectives might depend on other objectives.
isNotable()
Get to know if this is an interesting objective for a human.
getLabel()
Get a label that describes this objective.
achieve(Environment $environment)
Objectives can be achieved.
A configuration for the setup.
Definition: Config.php:27
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$ini
Definition: raiseError.php:20