ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilComponentFactoryExistsObjective.php
Go to the documentation of this file.
1 <?php
2 
20 declare(strict_types=1);
21 
22 use ILIAS\Setup;
23 
27 class ilComponentFactoryExistsObjective implements Setup\Objective
28 {
32  public function getHash(): string
33  {
34  return hash("sha256", self::class);
35  }
36 
40  public function getLabel(): string
41  {
42  return "ilComponentFactory is initialized and stored into the environment.";
43  }
44 
48  public function isNotable(): bool
49  {
50  return true;
51  }
52 
56  public function getPreconditions(Setup\Environment $environment): array
57  {
58  return [
59  new \ilDatabaseUpdatedObjective(),
60  new \ilComponentRepositoryExistsObjective()
61  ];
62  }
63 
67  public function achieve(Setup\Environment $environment): Setup\Environment
68  {
69  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
70  $component_repository = $environment->getResource(Setup\Environment::RESOURCE_COMPONENT_REPOSITORY);
71 
72  $component_factory = new ilComponentFactoryImplementation(
73  $component_repository,
74  $db
75  );
76 
77  return $environment->withResource(
78  Setup\Environment::RESOURCE_COMPONENT_FACTORY,
79  $component_factory
80  );
81  }
82 
86  public function isApplicable(Setup\Environment $environment): bool
87  {
88  return is_null($environment->getResource(Setup\Environment::RESOURCE_COMPONENT_FACTORY));
89  }
90 }
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...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27