ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 {
132  protected ilDatabaseSetupConfig $config;
140  public function readVariable(string $a_group, string $a_var_name): string
141  {
142  if ($a_group !== "db") {
143  throw new \LogicException(
144  "Can only access db-config via this mock."
145  );
146  }
147  switch ($a_var_name) {
148  case "user":
149  return $this->config->getUser();
150  case "host":
151  return $this->config->getHost();
152  case "port":
153  return (string) $this->config->getPort();
154  case "pass":
155  $pw = $this->config->getPassword();
156  return $pw ? $pw->toString() : "";
157  case "name":
158  return $this->config->getDatabase();
159  case "type":
160  return $this->config->getType();
161  default:
162  throw new \LogicException(
163  "Cannot provide variable '$a_var_name'"
164  );
165  }
166  }
167 
168  public function __construct(\ilDatabaseSetupConfig $config)
169  {
170  $this->config = $config;
171  }
172  public function read(): bool
173  {
174  throw new \LogicException("Just a mock here...");
175  }
176  public function parse(): bool
177  {
178  throw new \LogicException("Just a mock here...");
179  }
180  public function fixIniFile(): void
181  {
182  throw new \LogicException("Just a mock here...");
183  }
184  public function write(): bool
185  {
186  throw new \LogicException("Just a mock here...");
187  }
188  public function show(): string
189  {
190  throw new \LogicException("Just a mock here...");
191  }
192  public function getGroupCount(): int
193  {
194  throw new \LogicException("Just a mock here...");
195  }
196  public function readGroups(): array
197  {
198  throw new \LogicException("Just a mock here...");
199  }
200  public function groupExists(string $a_group_name): bool
201  {
202  throw new \LogicException("Just a mock here...");
203  }
204  public function readGroup(string $a_group_name): array
205  {
206  throw new \LogicException("Just a mock here...");
207  }
208  public function addGroup(string $a_group_name): bool
209  {
210  throw new \LogicException("Just a mock here...");
211  }
212  public function removeGroup(string $a_group_name): bool
213  {
214  throw new \LogicException("Just a mock here...");
215  }
216  public function variableExists(string $a_group, string $a_var_name): bool
217  {
218  throw new \LogicException("Just a mock here...");
219  }
220  public function setVariable(string $a_group_name, string $a_var_name, string $a_var_value): bool
221  {
222  throw new \LogicException("Just a mock here...");
223  }
224  public function error(string $a_errmsg): bool
225  {
226  throw new \LogicException("Just a mock here...");
227  }
228  public function getError(): string
229  {
230  throw new \LogicException("Just a mock here...");
231  }
232  };
233  }
__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: