ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDatabaseSetupConfig Class Reference
+ Inheritance diagram for ilDatabaseSetupConfig:
+ Collaboration diagram for ilDatabaseSetupConfig:

Public Member Functions

 __construct (string $type, string $host, string $database, string $user, protected ?Password $password=null, protected bool $create_database=true, ?string $collation=null, protected ?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 = "./components/ILIAS/setup_/sql/ilias3.sql"
 
ilDatabaseSetupConfig $config
 

Protected Attributes

string $type
 
string $host
 
string $database
 
string $collation
 
string $user
 
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,
protected ?Password  $password = null,
protected bool  $create_database = true,
?string  $collation = null,
protected ?int  $port = null,
?string  $path_to_db_dump = null 
)

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

53 {
54 if (!in_array($type, \ilDBConstants::getInstallableTypes())) {
55 throw new \InvalidArgumentException(
56 "Unknown database type: $type"
57 );
58 }
60 throw new \InvalidArgumentException(
61 "Unknown collation: $collation"
62 );
63 }
64 $this->type = trim($type);
65 $this->host = trim($host);
66 $this->database = trim($database);
67 $this->user = trim($user);
68 $this->collation = $collation ? trim($collation) : self::DEFAULT_COLLATION;
69 $this->path_to_db_dump = $path_to_db_dump ?? self::DEFAULT_PATH_TO_DB_DUMP;
70 }
static getAvailableCollations()
static getInstallableTypes()

References $collation, $database, $host, $path_to_db_dump, $type, $user, ILIAS\Repository\database(), 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 97 of file class.ilDatabaseSetupConfig.php.

97 : string
98 {
99 return $this->collation;
100 }

References $collation.

◆ getCreateDatabase()

ilDatabaseSetupConfig::getCreateDatabase ( )

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

92 : bool
93 {
94 return $this->create_database;
95 }

◆ getDatabase()

ilDatabaseSetupConfig::getDatabase ( )

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

87 : string
88 {
89 return $this->database;
90 }

References $database.

◆ getHost()

ilDatabaseSetupConfig::getHost ( )

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

77 : string
78 {
79 return $this->host;
80 }

References $host.

◆ getPassword()

ilDatabaseSetupConfig::getPassword ( )

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

107 : ?Password
108 {
109 return $this->password;
110 }
A password is used as part of credentials for authentication.
Definition: Password.php:31

◆ getPathToDBDump()

ilDatabaseSetupConfig::getPathToDBDump ( )

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

112 : string
113 {
115 }

References $path_to_db_dump.

◆ getPort()

ilDatabaseSetupConfig::getPort ( )

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

82 : ?int
83 {
84 return $this->port;
85 }

◆ getType()

ilDatabaseSetupConfig::getType ( )

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

72 : string
73 {
74 return $this->type;
75 }

References $type.

◆ getUser()

ilDatabaseSetupConfig::getUser ( )

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

102 : string
103 {
104 return $this->user;
105 }

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 120 of file class.ilDatabaseSetupConfig.php.

120 : \ilIniFile
121 {
122 return new class ($this) extends \ilIniFile {
130 public function readVariable(string $a_group, string $a_var_name): string
131 {
132 if ($a_group !== "db") {
133 throw new \LogicException(
134 "Can only access db-config via this mock."
135 );
136 }
137 switch ($a_var_name) {
138 case "user":
139 return $this->config->getUser();
140 case "host":
141 return $this->config->getHost();
142 case "port":
143 return (string) $this->config->getPort();
144 case "pass":
145 $pw = $this->config->getPassword();
146 return $pw !== null ? $pw->toString() : "";
147 case "name":
148 return $this->config->getDatabase();
149 case "type":
150 return $this->config->getType();
151 default:
152 throw new \LogicException(
153 "Cannot provide variable '$a_var_name'"
154 );
155 }
156 }
157
158 public function __construct(protected ilDatabaseSetupConfig $config)
159 {
160 }
161 public function read(): bool
162 {
163 throw new \LogicException("Just a mock here...");
164 }
165 public function parse(): bool
166 {
167 throw new \LogicException("Just a mock here...");
168 }
169 public function fixIniFile(): never
170 {
171 throw new \LogicException("Just a mock here...");
172 }
173 public function write(): bool
174 {
175 throw new \LogicException("Just a mock here...");
176 }
177 public function show(): string
178 {
179 throw new \LogicException("Just a mock here...");
180 }
181 public function getGroupCount(): int
182 {
183 throw new \LogicException("Just a mock here...");
184 }
185 public function readGroups(): array
186 {
187 throw new \LogicException("Just a mock here...");
188 }
189 public function groupExists(string $a_group_name): bool
190 {
191 throw new \LogicException("Just a mock here...");
192 }
193 public function readGroup(string $a_group_name): array
194 {
195 throw new \LogicException("Just a mock here...");
196 }
197 public function addGroup(string $a_group_name): bool
198 {
199 throw new \LogicException("Just a mock here...");
200 }
201 public function removeGroup(string $a_group_name): bool
202 {
203 throw new \LogicException("Just a mock here...");
204 }
205 public function variableExists(string $a_group, string $a_var_name): bool
206 {
207 throw new \LogicException("Just a mock here...");
208 }
209 public function setVariable(string $a_group_name, string $a_var_name, string $a_var_value): bool
210 {
211 throw new \LogicException("Just a mock here...");
212 }
213 public function error(string $a_errmsg): bool
214 {
215 throw new \LogicException("Just a mock here...");
216 }
217 public function getError(): string
218 {
219 throw new \LogicException("Just a mock here...");
220 }
221 };
222 }
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, protected ?Password $password=null, protected bool $create_database=true, ?string $collation=null, protected ?int $port=null, ?string $path_to_db_dump=null)
INIFile Parser Early access in init proceess! Avoid further dependencies like logging or other servic...

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 35 of file class.ilDatabaseSetupConfig.php.

Referenced by __construct(), and getCollation().

◆ $config

ilDatabaseSetupConfig ilDatabaseSetupConfig::$config

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

Referenced by toMockIniFile().

◆ $database

string ilDatabaseSetupConfig::$database
protected

Definition at line 33 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().

◆ $path_to_db_dump

string ilDatabaseSetupConfig::$path_to_db_dump
protected

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

Referenced by __construct(), and getPathToDBDump().

◆ $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 37 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 = "./components/ILIAS/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: