ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMakeInstallationAccessibleObjective.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 
8 {
9  public function getHash() : string
10  {
11  return hash("sha256", self::class);
12  }
13 
14  public function getLabel() : string
15  {
16  return "The installation is accessible.";
17  }
18 
19  public function isNotable() : bool
20  {
21  return true;
22  }
23 
24  public function getPreconditions(Setup\Environment $environment) : array
25  {
26  $db_config = $environment->getConfigFor("database");
27  return [
28  new \ilIniFilesPopulatedObjective($this->config),
29  new ilDatabasePopulatedObjective($db_config),
30  new \ilSettingsFactoryExistsObjective()
31  ];
32  }
33 
34  public function achieve(Setup\Environment $environment) : Setup\Environment
35  {
36  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
37  $settings = $factory->settingsFor("common");
38 
39  $settings->set("setup_ok", 1);
40 
41  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
42 
43  $client_ini->setVariable("client", "access", true);
44 
45  if (!$client_ini->write()) {
46  throw new Setup\UnachievableException("Could not write client.ini.php");
47  }
48 
49  return $environment;
50  }
51 
55  public function isApplicable(Setup\Environment $environment) : bool
56  {
57  $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
58  $settings = $factory->settingsFor("common");
59  $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
60 
61  return
62  $settings->get("setup_ok") != 1 ||
63  $client_ini->readVariable("client", "access") != true
64  ;
65  }
66 }
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:11
$factory
Definition: metadata.php:58