ILIAS  release_8 Revision v8.24
class.ilLoggingConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
6
7
12
14{
15 protected Config $config;
16
17 public function __construct(Config $config)
18 {
19 $this->config = $config;
20 }
21
22 public function getHash(): string
23 {
24 return hash("sha256", self::class);
25 }
26
27 public function getLabel(): string
28 {
29 return "Fill ini with settings for Services/Logging";
30 }
31
32 public function isNotable(): bool
33 {
34 return false;
35 }
36
37 public function getPreconditions(Environment $environment): array
38 {
39 return [
41 ];
42 }
43
44 public function achieve(Environment $environment): 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 }
70
74 public function isApplicable(Environment $environment): 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 }
93}
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
bool $enabled
Whether the system instance is enabled to accept connection requests.
Definition: System.php:123
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4