ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilVirusScannerConfigStoredObjective.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 use ILIAS\Setup;
6 
7 class ilVirusScannerConfigStoredObjective implements Setup\Objective
8 {
12  protected $config;
13 
14  public function __construct(
16  ) {
17  $this->config = $config;
18  }
19 
20  public function getHash() : string
21  {
22  return hash("sha256", self::class);
23  }
24 
25  public function getLabel() : string
26  {
27  return "Fill ini with settings for Services/VirusScanner";
28  }
29 
30  public function isNotable() : bool
31  {
32  return false;
33  }
34 
35  public function getPreconditions(Setup\Environment $environment) : array
36  {
37  $common_config = $environment->getConfigFor("common");
38  return [
39  new ilIniFilesPopulatedObjective($common_config)
40  ];
41  }
42 
43  public function achieve(Setup\Environment $environment) : Setup\Environment
44  {
45  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
46 
47  $ini->setVariable("tools", "vscantype", $this->config->getVirusScanner());
48  $ini->setVariable("tools", "scancommand", $this->config->getPathToScan());
49  $ini->setVariable("tools", "cleancommand", $this->config->getPathToClean());
50 
51  if (!$ini->write()) {
52  throw new Setup\UnachievableException("Could not write ilias.ini.php");
53  }
54 
55  return $environment;
56  }
57 }
An environment holds resources to be used in the setup process.
Definition: Environment.php:11
$ini
Definition: raiseError.php:4