ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCtrlStructureStoredObjective.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
3 use ILIAS\Setup;
4 
5 class ilCtrlStructureStoredObjective implements Setup\Objective
6 {
7  const TABLE_CLASSFILES = "ctrl_classfile";
8  const TABLE_CALLS = "ctrl_calls";
9 
13  protected $ctrl_reader;
14 
18  protected $populate_before;
19 
21  {
22  $this->ctrl_reader = $ctrl_reader;
23  $this->populate_before = $populate_before;
24  }
25 
29  public function getHash() : string
30  {
31  return hash("sha256", self::class);
32  }
33 
37  public function getLabel() : string
38  {
39  return "ilCtrl-structure is read and stored.";
40  }
41 
45  public function isNotable() : bool
46  {
47  return true;
48  }
49 
53  public function getPreconditions(Setup\Environment $environment) : array
54  {
55  $config = $environment->getConfigFor('database');
56  return [
57  new \ilDatabaseUpdatedObjective($config, $this->populate_before)
58  ];
59  }
60 
64  public function achieve(Setup\Environment $environment) : Setup\Environment
65  {
66  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
67  if (!$db) {
68  throw new \UnachievableException("Need DB to store control-structure");
69  }
70 
71  if (!defined("ILIAS_ABSOLUTE_PATH")) {
72  define("ILIAS_ABSOLUTE_PATH", dirname(__FILE__, 5));
73  }
74 
75  $reader = $this->ctrl_reader->withDB($db);
76  $reader->executed = false;
77  $reader->readStructure(true);
78  return $environment;
79  }
80 }
getPreconditions(Setup\Environment $environment)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
Class ilCtrlStructureReader.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
An environment holds resources to be used in the setup process.
Definition: Environment.php:11
__construct(\ilCtrlStructureReader $ctrl_reader, bool $populate_before=true)