ILIAS  release_8 Revision v8.24
class.ilVirusScannerConfigStoredObjective.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Setup;
22
24{
26
27 public function __construct(
29 ) {
30 $this->config = $config;
31 }
32
33 public function getHash(): string
34 {
35 return hash("sha256", self::class);
36 }
37
38 public function getLabel(): string
39 {
40 return "Fill ini with settings for Services/VirusScanner";
41 }
42
43 public function isNotable(): bool
44 {
45 return false;
46 }
47
51 public function getPreconditions(Setup\Environment $environment): array
52 {
53 return [
55 ];
56 }
57
58 public function achieve(Setup\Environment $environment): Setup\Environment
59 {
60 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
61
62 $ini->setVariable("tools", "vscantype", $this->config->getVirusScanner());
63 $ini->setVariable("tools", "scancommand", (string) $this->config->getPathToScan());
64 $ini->setVariable("tools", "cleancommand", (string) $this->config->getPathToClean());
65 $ini->setVariable("tools", "icap_host", (string) $this->config->getIcapHost());
66 $ini->setVariable("tools", "icap_port", (string) $this->config->getIcapPort());
67 $ini->setVariable("tools", "icap_service_name", (string) $this->config->getIcapServiceName());
68 $ini->setVariable("tools", "icap_client_path", (string) $this->config->getIcapClientPath());
69
70 if (!$ini->write()) {
71 throw new Setup\UnachievableException("Could not write ilias.ini.php");
72 }
73
74 return $environment;
75 }
76
77 public function isApplicable(Setup\Environment $environment): bool
78 {
79 $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
80
81 return
82 $ini->readVariable("tools", "vscantype") !== $this->config->getVirusScanner() ||
83 $ini->readVariable("tools", "scancommand") !== $this->config->getPathToScan() ||
84 $ini->readVariable("tools", "cleancommand") !== $this->config->getPathToClean() ||
85 $ini->readVariable("tools", "icap_host") !== $this->config->getIcapHost() ||
86 $ini->readVariable("tools", "icap_port") !== $this->config->getIcapPort() ||
87 $ini->readVariable("tools", "icap_service_name") !== $this->config->getIcapServiceName() ||
88 $ini->readVariable("tools", "icap_client_path") !== $this->config->getIcapClientPath();
89 }
90}
Signals that some goal won't be achievable by actions of the system ever.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ini
Definition: raiseError.php:4