ILIAS  release_8 Revision v8.23
ilDatabaseSetupConfig Class Reference
+ Inheritance diagram for ilDatabaseSetupConfig:
+ Collaboration diagram for ilDatabaseSetupConfig:

Public Member Functions

 __construct (string $type, string $host, string $database, string $user, Password $password=null, bool $create_database=true, string $collation=null, int $port=null, string $path_to_db_dump=null)
 
 getType ()
 
 getHost ()
 
 getPort ()
 
 getDatabase ()
 
 getCreateDatabase ()
 
 getCollation ()
 
 getUser ()
 
 getPassword ()
 
 getPathToDBDump ()
 
 toMockIniFile ()
 Adapter to current database-handling via a mock of . More...
 

Data Fields

const DEFAULT_COLLATION = "utf8_general_ci"
 
const DEFAULT_PATH_TO_DB_DUMP = "./setup/sql/ilias3.sql"
 
ilDatabaseSetupConfig $config
 

Protected Attributes

string $type
 
string $host
 
int $port = null
 
string $database
 
bool $create_database
 
string $collation
 
string $user
 
ILIAS Data Password $password = null
 
string $path_to_db_dump
 

Detailed Description

Definition at line 24 of file class.ilDatabaseSetupConfig.php.

Constructor & Destructor Documentation

◆ __construct()

ilDatabaseSetupConfig::__construct ( string  $type,
string  $host,
string  $database,
string  $user,
Password  $password = null,
bool  $create_database = true,
string  $collation = null,
int  $port = null,
string  $path_to_db_dump = null 
)

Definition at line 49 of file class.ilDatabaseSetupConfig.php.

References $create_database, $password, $port, ilDBConstants\getAvailableCollations(), ilDBConstants\getInstallableTypes(), and ILIAS\Repository\user().

Referenced by toMockIniFile().

59  {
60  if (!in_array($type, \ilDBConstants::getInstallableTypes())) {
61  throw new \InvalidArgumentException(
62  "Unknown database type: $type"
63  );
64  }
65  if ($collation && !in_array(trim($collation), \ilDBConstants::getAvailableCollations())) {
66  throw new \InvalidArgumentException(
67  "Unknown collation: $collation"
68  );
69  }
70  $this->type = trim($type);
71  $this->host = trim($host);
72  $this->database = trim($database);
73  $this->user = trim($user);
74  $this->password = $password;
75  $this->create_database = $create_database;
76  $this->collation = $collation ? trim($collation) : self::DEFAULT_COLLATION;
77  $this->port = $port;
78  $this->path_to_db_dump = $path_to_db_dump ?? self::DEFAULT_PATH_TO_DB_DUMP;
79  }
static getAvailableCollations()
static getInstallableTypes()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ getCollation()

ilDatabaseSetupConfig::getCollation ( )

Definition at line 106 of file class.ilDatabaseSetupConfig.php.

References $collation.

106  : string
107  {
108  return $this->collation;
109  }

◆ getCreateDatabase()

ilDatabaseSetupConfig::getCreateDatabase ( )

Definition at line 101 of file class.ilDatabaseSetupConfig.php.

References $create_database.

101  : bool
102  {
103  return $this->create_database;
104  }

◆ getDatabase()

ilDatabaseSetupConfig::getDatabase ( )

Definition at line 96 of file class.ilDatabaseSetupConfig.php.

References $database.

96  : string
97  {
98  return $this->database;
99  }

◆ getHost()

ilDatabaseSetupConfig::getHost ( )

Definition at line 86 of file class.ilDatabaseSetupConfig.php.

References $host.

86  : string
87  {
88  return $this->host;
89  }

◆ getPassword()

ilDatabaseSetupConfig::getPassword ( )

Definition at line 116 of file class.ilDatabaseSetupConfig.php.

References $password.

116  : ?Password
117  {
118  return $this->password;
119  }
A password is used as part of credentials for authentication.
Definition: Password.php:16

◆ getPathToDBDump()

ilDatabaseSetupConfig::getPathToDBDump ( )

Definition at line 121 of file class.ilDatabaseSetupConfig.php.

References $path_to_db_dump.

121  : string
122  {
123  return $this->path_to_db_dump;
124  }

◆ getPort()

ilDatabaseSetupConfig::getPort ( )

Definition at line 91 of file class.ilDatabaseSetupConfig.php.

References $port.

91  : ?int
92  {
93  return $this->port;
94  }

◆ getType()

ilDatabaseSetupConfig::getType ( )

Definition at line 81 of file class.ilDatabaseSetupConfig.php.

References $type.

81  : string
82  {
83  return $this->type;
84  }

◆ getUser()

ilDatabaseSetupConfig::getUser ( )

Definition at line 111 of file class.ilDatabaseSetupConfig.php.

References $user.

111  : string
112  {
113  return $this->user;
114  }

◆ toMockIniFile()

ilDatabaseSetupConfig::toMockIniFile ( )

Adapter to current database-handling via a mock of .

reads a single variable from a group public

Parameters
stringgroup name
stringvalue
Returns
mixed|void return value string or boolean 'false' on failure

Definition at line 129 of file class.ilDatabaseSetupConfig.php.

References $config, and __construct().

129  : \ilIniFile
130  {
131  return new class ($this) extends \ilIniFile {
139  public function readVariable(string $a_group, string $a_var_name): string
140  {
141  if ($a_group !== "db") {
142  throw new \LogicException(
143  "Can only access db-config via this mock."
144  );
145  }
146  switch ($a_var_name) {
147  case "user":
148  return $this->config->getUser();
149  case "host":
150  return $this->config->getHost();
151  case "port":
152  return (string) $this->config->getPort();
153  case "pass":
154  $pw = $this->config->getPassword();
155  return $pw ? $pw->toString() : "";
156  case "name":
157  return $this->config->getDatabase();
158  case "type":
159  return $this->config->getType();
160  default:
161  throw new \LogicException(
162  "Cannot provide variable '$a_var_name'"
163  );
164  }
165  }
166 
167  public function __construct(\ilDatabaseSetupConfig $config)
168  {
169  $this->config = $config;
170  }
171  public function read(): bool
172  {
173  throw new \LogicException("Just a mock here...");
174  }
175  public function parse(): bool
176  {
177  throw new \LogicException("Just a mock here...");
178  }
179  public function fixIniFile(): void
180  {
181  throw new \LogicException("Just a mock here...");
182  }
183  public function write(): bool
184  {
185  throw new \LogicException("Just a mock here...");
186  }
187  public function show(): string
188  {
189  throw new \LogicException("Just a mock here...");
190  }
191  public function getGroupCount(): int
192  {
193  throw new \LogicException("Just a mock here...");
194  }
195  public function readGroups(): array
196  {
197  throw new \LogicException("Just a mock here...");
198  }
199  public function groupExists(string $a_group_name): bool
200  {
201  throw new \LogicException("Just a mock here...");
202  }
203  public function readGroup(string $a_group_name): array
204  {
205  throw new \LogicException("Just a mock here...");
206  }
207  public function addGroup(string $a_group_name): bool
208  {
209  throw new \LogicException("Just a mock here...");
210  }
211  public function removeGroup(string $a_group_name): bool
212  {
213  throw new \LogicException("Just a mock here...");
214  }
215  public function variableExists(string $a_group, string $a_var_name): bool
216  {
217  throw new \LogicException("Just a mock here...");
218  }
219  public function setVariable(string $a_group_name, string $a_var_name, string $a_var_value): bool
220  {
221  throw new \LogicException("Just a mock here...");
222  }
223  public function error(string $a_errmsg): bool
224  {
225  throw new \LogicException("Just a mock here...");
226  }
227  public function getError(): string
228  {
229  throw new \LogicException("Just a mock here...");
230  }
231  };
232  }
__construct(string $type, string $host, string $database, string $user, Password $password=null, bool $create_database=true, string $collation=null, int $port=null, string $path_to_db_dump=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Field Documentation

◆ $collation

string ilDatabaseSetupConfig::$collation
protected

Definition at line 39 of file class.ilDatabaseSetupConfig.php.

Referenced by getCollation().

◆ $config

ilDatabaseSetupConfig ilDatabaseSetupConfig::$config

Definition at line 47 of file class.ilDatabaseSetupConfig.php.

Referenced by toMockIniFile().

◆ $create_database

bool ilDatabaseSetupConfig::$create_database
protected

Definition at line 37 of file class.ilDatabaseSetupConfig.php.

Referenced by __construct(), and getCreateDatabase().

◆ $database

string ilDatabaseSetupConfig::$database
protected

Definition at line 35 of file class.ilDatabaseSetupConfig.php.

Referenced by getDatabase().

◆ $host

string ilDatabaseSetupConfig::$host
protected

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

Referenced by getHost().

◆ $password

ILIAS Data Password ilDatabaseSetupConfig::$password = null
protected

Definition at line 43 of file class.ilDatabaseSetupConfig.php.

Referenced by __construct(), and getPassword().

◆ $path_to_db_dump

string ilDatabaseSetupConfig::$path_to_db_dump
protected

Definition at line 45 of file class.ilDatabaseSetupConfig.php.

Referenced by getPathToDBDump().

◆ $port

int ilDatabaseSetupConfig::$port = null
protected

Definition at line 33 of file class.ilDatabaseSetupConfig.php.

Referenced by __construct(), and getPort().

◆ $type

string ilDatabaseSetupConfig::$type
protected

Definition at line 29 of file class.ilDatabaseSetupConfig.php.

Referenced by getType().

◆ $user

string ilDatabaseSetupConfig::$user
protected

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

Referenced by getUser().

◆ DEFAULT_COLLATION

const ilDatabaseSetupConfig::DEFAULT_COLLATION = "utf8_general_ci"

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

◆ DEFAULT_PATH_TO_DB_DUMP

const ilDatabaseSetupConfig::DEFAULT_PATH_TO_DB_DUMP = "./setup/sql/ilias3.sql"

Definition at line 27 of file class.ilDatabaseSetupConfig.php.


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