ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMakeInstallationAccessibleObjective.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 use ILIAS\Setup;
22 
24 {
25  public function getHash(): string
26  {
27  return hash("sha256", self::class);
28  }
29 
30  public function getLabel(): string
31  {
32  return "The installation is accessible.";
33  }
34 
35  public function isNotable(): bool
36  {
37  return true;
38  }
39 
40  public function getPreconditions(Setup\Environment $environment): array
41  {
42  $db_config = $environment->getConfigFor("database");
43  return [
44  new \ilIniFilesPopulatedObjective(),
45  new ilDatabasePopulatedObjective($db_config),
46  new \ilSettingsFactoryExistsObjective()
47  ];
48  }
49 
50  public function achieve(Setup\Environment $environment): Setup\Environment
51  {
52  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
53  $settings = $factory->settingsFor("common");
54 
55  $settings->set("setup_ok", "1");
56 
57  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
58 
59  $client_ini->setVariable("client", "access", '1');
60 
61  if (!$client_ini->write()) {
62  throw new Setup\UnachievableException("Could not write client.ini.php");
63  }
64 
65  return $environment;
66  }
67 
71  public function isApplicable(Setup\Environment $environment): bool
72  {
73  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
74  $settings = $factory->settingsFor("common");
75  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
76 
77  return
78  $settings->get("setup_ok") != 1 ||
79  $client_ini->readVariable("client", "access") != true
80  ;
81  }
82 }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
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
$factory
Definition: metadata.php:75