ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDatabasePopulatedObjective Class Reference
+ Inheritance diagram for ilDatabasePopulatedObjective:
+ Collaboration diagram for ilDatabasePopulatedObjective:

Public Member Functions

 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 getPreconditions (Setup\Environment $environment)
 
 achieve (Setup\Environment $environment)
 
- Public Member Functions inherited from ilDatabaseObjective
 __construct (\ilDatabaseSetupConfig $config)
 

Data Fields

const MIN_NUMBER_OF_ILIAS_TABLES = 200
 

Protected Member Functions

 isDatabasePopulated (\ilDBInterface $db)
 

Additional Inherited Members

- Protected Attributes inherited from ilDatabaseObjective
 $config
 

Detailed Description

Definition at line 7 of file class.ilDatabasePopulatedObjective.php.

Member Function Documentation

◆ achieve()

ilDatabasePopulatedObjective::achieve ( Setup\Environment  $environment)

Definition at line 41 of file class.ilDatabasePopulatedObjective.php.

References ILIAS\Setup\Environment\getResource(), and isDatabasePopulated().

41  : Setup\Environment
42  {
43  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
44 
45  if ($this->isDatabasePopulated($db)) {
46  return $environment;
47  }
48 
49  $path_to_db_dump = $this->config->getPathToDBDump();
50  if (!is_file(realpath($path_to_db_dump)) ||
51  !is_readable(realpath($path_to_db_dump))) {
52  throw new Setup\UnachievableException(
53  "Cannot read database dump file: $path_to_db_dump"
54  );
55  }
56 
57  $sql = file_get_contents(realpath($path_to_db_dump));
58  $statement = $db->prepareManip($sql);
59  $db->execute($statement);
60 
61  return $environment;
62  }
+ Here is the call graph for this function:

◆ getHash()

ilDatabasePopulatedObjective::getHash ( )

Definition at line 11 of file class.ilDatabasePopulatedObjective.php.

11  : string
12  {
13  return hash("sha256", implode("-", [
14  self::class,
15  $this->config->getHost(),
16  $this->config->getPort(),
17  $this->config->getDatabase()
18  ]));
19  }

◆ getLabel()

ilDatabasePopulatedObjective::getLabel ( )

Definition at line 21 of file class.ilDatabasePopulatedObjective.php.

21  : string
22  {
23  return "The database is populated with ILIAS-tables.";
24  }

◆ getPreconditions()

ilDatabasePopulatedObjective::getPreconditions ( Setup\Environment  $environment)

Definition at line 31 of file class.ilDatabasePopulatedObjective.php.

31  : array
32  {
33  if ($environment->getResource(Setup\Environment::RESOURCE_DATABASE)) {
34  return [];
35  }
36  return [
37  new \ilDatabaseExistsObjective($this->config)
38  ];
39  }

◆ isDatabasePopulated()

ilDatabasePopulatedObjective::isDatabasePopulated ( \ilDBInterface  $db)
protected

Definition at line 64 of file class.ilDatabasePopulatedObjective.php.

References ilDBInterface\listTables().

Referenced by achieve().

65  {
66  $probe_tables = ['usr_data', 'object_data', 'object_reference'];
67  $number_of_probe_tables = count($probe_tables);
68  $tables = $db->listTables();
69  $number_of_tables = count($tables);
70 
71  return
72  $number_of_tables > self::MIN_NUMBER_OF_ILIAS_TABLES
73  && count(array_intersect($tables, $probe_tables)) == $number_of_probe_tables;
74  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNotable()

ilDatabasePopulatedObjective::isNotable ( )

Definition at line 26 of file class.ilDatabasePopulatedObjective.php.

26  : bool
27  {
28  return true;
29  }

Field Documentation

◆ MIN_NUMBER_OF_ILIAS_TABLES

const ilDatabasePopulatedObjective::MIN_NUMBER_OF_ILIAS_TABLES = 200

Definition at line 9 of file class.ilDatabasePopulatedObjective.php.


The documentation for this class was generated from the following file: