ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPreviewConfigStoredObjective.php
Go to the documentation of this file.
1 <?php
2 
19 use ILIAS\Setup;
20 
21 class ilPreviewConfigStoredObjective implements Setup\Objective
22 {
23  protected \ilPreviewSetupConfig $config;
24 
25  public function __construct(
26  \ilPreviewSetupConfig $config
27  ) {
28  $this->config = $config;
29  }
30 
31  public function getHash(): string
32  {
33  return hash("sha256", self::class);
34  }
35 
36  public function getLabel(): string
37  {
38  return "Store configuration of Services/Preview";
39  }
40 
41  public function isNotable(): bool
42  {
43  return false;
44  }
45 
49  public function getPreconditions(Setup\Environment $environment): array
50  {
51  return [
53  ];
54  }
55 
56  public function achieve(Setup\Environment $environment): Setup\Environment
57  {
58  $ini = $environment->getResource(Setup\Environment::RESOURCE_ILIAS_INI);
59 
60  $ini->setVariable(
61  "tools",
62  "ghostscript",
63  $this->config->getPathToGhostscript() ?? ''
64  );
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 $ini->readVariable("tools", "ghostscript") !== $this->config->getPathToGhostscript();
81  }
82 }
getPreconditions(Setup\Environment $environment)
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