ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilUtilitiesConfigStoredObjective.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 use ILIAS\Setup;
22 
27 class ilUtilitiesConfigStoredObjective implements Setup\Objective
28 {
30 
31  public function __construct(ilUtilitiesSetupConfig $config)
32  {
33  $this->config = $config;
34  }
35 
36  public function getHash(): string
37  {
38  return hash("sha256", self::class);
39  }
40 
41  public function getLabel(): string
42  {
43  return "Store configuration of Services/Utilities";
44  }
45 
46  public function isNotable(): bool
47  {
48  return false;
49  }
50 
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", "convert", $this->config->getPathToConvert());
63  $ini->setVariable("tools", "zip", $this->config->getPathToZip());
64  $ini->setVariable("tools", "unzip", $this->config->getPathToUnzip());
65 
66  if (!$ini->write()) {
67  throw new Setup\UnachievableException("Could not write ilias.ini.php");
68  }
69 
70  return $environment;
71  }
72 
76  public function isApplicable(Setup\Environment $environment): bool
77  {
78  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
79 
80  return
81  $ini->readVariable("tools", "convert") !== $this->config->getPathToConvert() ||
82  $ini->readVariable("tools", "zip") !== $this->config->getPathToZip() ||
83  $ini->readVariable("tools", "unzip") !== $this->config->getPathToUnzip();
84  }
85 }
Stores configuration for the Utilities service (paths to various tools) in the according ini-fields...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
$ini
Definition: raiseError.php:4