ILIAS  release_8 Revision v8.24
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 \ilIniFile. 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.

59 {
60 if (!in_array($type, \ilDBConstants::getInstallableTypes())) {
61 throw new \InvalidArgumentException(
62 "Unknown database type: $type"
63 );
64 }
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()

References $collation, $create_database, $database, $host, $password, $path_to_db_dump, $port, $type, $user, DEFAULT_COLLATION, DEFAULT_PATH_TO_DB_DUMP, ilDBConstants\getAvailableCollations(), ilDBConstants\getInstallableTypes(), and ILIAS\Repository\user().

Referenced by toMockIniFile().

+ 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.

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

References $collation.

◆ getCreateDatabase()

ilDatabaseSetupConfig::getCreateDatabase ( )

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

101 : bool
102 {
104 }

References $create_database.

◆ getDatabase()

ilDatabaseSetupConfig::getDatabase ( )

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

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

References $database.

◆ getHost()

ilDatabaseSetupConfig::getHost ( )

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

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

References $host.

◆ getPassword()

ilDatabaseSetupConfig::getPassword ( )

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

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

References $password.

◆ getPathToDBDump()

ilDatabaseSetupConfig::getPathToDBDump ( )

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

121 : string
122 {
124 }

References $path_to_db_dump.

◆ getPort()

ilDatabaseSetupConfig::getPort ( )

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

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

References $port.

◆ getType()

ilDatabaseSetupConfig::getType ( )

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

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

References $type.

◆ getUser()

ilDatabaseSetupConfig::getUser ( )

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

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

References $user.

◆ toMockIniFile()

ilDatabaseSetupConfig::toMockIniFile ( )

Adapter to current database-handling via a mock of \ilIniFile.

reads a single variable from a group @access 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.

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
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 }
variableExists(string $a_group, string $a_var_name)
returns if a variable exists or not
getError()
show()
returns the content of IniFile
readGroups()
returns an array with the names of all the groups
getGroupCount()
returns number of groups
error(string $a_errmsg)
removeGroup(string $a_group_name)
removes a group
readGroup(string $a_group_name)
returns an associative array of the variables in one group
setVariable(string $a_group_name, string $a_var_name, string $a_var_value)
sets a variable in a group
readVariable(string $a_group, string $a_var_name)
reads a single variable from a group
groupExists(string $a_group_name)
checks if a group exists
addGroup(string $a_group_name)
adds a new group
__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...

References $config, __construct(), addGroup(), error(), getError(), getGroupCount(), groupExists(), readGroup(), readGroups(), readVariable(), removeGroup(), setVariable(), show(), and variableExists().

+ 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 __construct(), and 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 __construct(), and getDatabase().

◆ $host

string ilDatabaseSetupConfig::$host
protected

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

Referenced by __construct(), and 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 __construct(), and 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 __construct(), and getType().

◆ $user

string ilDatabaseSetupConfig::$user
protected

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

Referenced by __construct(), and getUser().

◆ DEFAULT_COLLATION

const ilDatabaseSetupConfig::DEFAULT_COLLATION = "utf8_general_ci"

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

Referenced by __construct().

◆ 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.

Referenced by __construct().


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