ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSettingsFactoryExistsObjective.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
21 use ILIAS\Setup;
22 
26 class ilSettingsFactoryExistsObjective implements Setup\Objective
27 {
28  public function getHash(): string
29  {
30  return hash("sha256", self::class);
31  }
32 
33  public function getLabel(): string
34  {
35  return "Initialize factory for ilSetting";
36  }
37 
38  public function isNotable(): bool
39  {
40  return false;
41  }
42 
43  public function getPreconditions(Setup\Environment $environment): array
44  {
45  return [
47  ];
48  }
49 
50  public function achieve(Setup\Environment $environment): Setup\Environment
51  {
52  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
53 
54  if (!($db instanceof \ilDBInterface)) {
55  throw new Setup\UnachievableException("Database does not exist.");
56  }
57 
58  return $environment
59  ->withResource(
60  Setup\Environment::RESOURCE_SETTINGS_FACTORY,
61  new \ilSettingsFactory($db)
62  );
63  }
64 
65  public function isApplicable(Setup\Environment $environment): bool
66  {
67  $resource = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
68 
69  return !($resource instanceof ilSettingsFactory);
70  }
71 }
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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