ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDatabaseSetupConfig Class Reference
+ Inheritance diagram for ilDatabaseSetupConfig:
+ Collaboration diagram for ilDatabaseSetupConfig:

Public Member Functions

 __construct ( $type, string $host, string $database, string $user, Password $password=null, bool $create_database=true, string $collation=null, string $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"
 

Protected Attributes

 $type
 
 $host
 
 $port
 
 $database
 
 $create_database
 
 $collation
 
 $user
 
 $password
 
 $path_to_db_dump
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

68 {
69 if (!in_array($type, \ilDBConstants::getInstallableTypes())) {
70 throw new \InvalidArgumentException(
71 "Unknown database type: $type"
72 );
73 }
75 throw new \InvalidArgumentException(
76 "Unknown collation: $collation"
77 );
78 }
79 $this->type = trim($type);
80 $this->host = trim($host);
81 $this->database = trim($database);
82 $this->user = trim($user);
83 $this->password = $password;
84 $this->create_database = trim($create_database);
85 $this->collation = $collation ? trim($collation) : self::DEFAULT_COLLATION;
86 $this->port = $port;
87 $this->path_to_db_dump = $path_to_db_dump ?? self::DEFAULT_PATH_TO_DB_DUMP;
88 }
user()
Definition: user.php:4
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 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 115 of file class.ilDatabaseSetupConfig.php.

115 : string
116 {
117 return $this->collation;
118 }

References $collation.

◆ getCreateDatabase()

ilDatabaseSetupConfig::getCreateDatabase ( )

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

110 : bool
111 {
113 }

References $create_database.

◆ getDatabase()

ilDatabaseSetupConfig::getDatabase ( )

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

105 : string
106 {
107 return $this->database;
108 }

References $database.

◆ getHost()

ilDatabaseSetupConfig::getHost ( )

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

95 : string
96 {
97 return $this->host;
98 }

References $host.

◆ getPassword()

ilDatabaseSetupConfig::getPassword ( )

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

125 : ?Password
126 {
127 return $this->password;
128 }
A password is used as part of credentials for authentication.
Definition: Password.php:14

References $password.

◆ getPathToDBDump()

ilDatabaseSetupConfig::getPathToDBDump ( )

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

130 : string
131 {
133 }

References $path_to_db_dump.

◆ getPort()

ilDatabaseSetupConfig::getPort ( )

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

100 : ?string
101 {
102 return $this->port;
103 }

References $port.

◆ getType()

ilDatabaseSetupConfig::getType ( )

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

91 {
92 return $this->type;
93 }

References $type.

◆ getUser()

ilDatabaseSetupConfig::getUser ( )

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

120 : string
121 {
122 return $this->user;
123 }

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 return value string or boolean 'false' on failure

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

138 : \ilIniFile
139 {
140 return new class($this) extends \ilIniFile {
148 public function readVariable($a_group, $a_var_name)
149 {
150 if ($a_group !== "db") {
151 throw new \LogicException(
152 "Can only access db-config via this mock."
153 );
154 }
155 switch ($a_var_name) {
156 case "user":
157 return $this->config->getUser();
158 case "host":
159 return $this->config->getHost();
160 case "port":
161 return $this->config->getPort();
162 case "pass":
163 $pw = $this->config->getPassword();
164 return $pw ? $pw->toString() : null;
165 case "name":
166 return $this->config->getDatabase();
167 case "type":
168 return $this->config->getType();
169 default:
170 throw new \LogicException(
171 "Cannot provide variable '$a_var_name'"
172 );
173 }
174 }
176 {
177 $this->config = $config;
178 }
179 public function read()
180 {
181 throw new \LogicException("Just a mock here...");
182 }
183 public function parse()
184 {
185 throw new \LogicException("Just a mock here...");
186 }
187 public function fixIniFile()
188 {
189 throw new \LogicException("Just a mock here...");
190 }
191 public function write()
192 {
193 throw new \LogicException("Just a mock here...");
194 }
195 public function show()
196 {
197 throw new \LogicException("Just a mock here...");
198 }
199 public function getGroupCount()
200 {
201 throw new \LogicException("Just a mock here...");
202 }
203 public function readGroups()
204 {
205 throw new \LogicException("Just a mock here...");
206 }
207 public function groupExists($a_group_name)
208 {
209 throw new \LogicException("Just a mock here...");
210 }
211 public function readGroup($a_group_name)
212 {
213 throw new \LogicException("Just a mock here...");
214 }
215 public function addGroup($a_group_name)
216 {
217 throw new \LogicException("Just a mock here...");
218 }
219 public function removeGroup($a_group_name)
220 {
221 throw new \LogicException("Just a mock here...");
222 }
223 public function variableExists($a_group, $a_var_name)
224 {
225 throw new \LogicException("Just a mock here...");
226 }
227 public function setVariable($a_group_name, $a_var_name, $a_var_value)
228 {
229 throw new \LogicException("Just a mock here...");
230 }
231 public function error($a_errmsg)
232 {
233 throw new \LogicException("Just a mock here...");
234 }
235 public function getError()
236 {
237 throw new \LogicException("Just a mock here...");
238 }
239 };
240 }
getError()
returns error @access public
show()
returns the content of IniFile @access public
readGroups()
returns an array with the names of all the groups @access public
variableExists($a_group, $a_var_name)
returns if a variable exists or not @access public
getGroupCount()
returns number of groups @access public
removeGroup($a_group_name)
removes a group @access public
readGroup($a_group_name)
returns an associative array of the variables in one group @access public
addGroup($a_group_name)
adds a new group @access public
readVariable($a_group, $a_var_name)
reads a single variable from a group @access public
setVariable($a_group_name, $a_var_name, $a_var_value)
sets a variable in a group @access public
groupExists($a_group_name)
checks if a group exists @access public
error($a_errmsg)
set error message @access public
__construct( $type, string $host, string $database, string $user, Password $password=null, bool $create_database=true, string $collation=null, string $port=null, string $path_to_db_dump=null)
INIFile Parser.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68

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

ilDatabaseSetupConfig::$collation
protected

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

Referenced by __construct(), and getCollation().

◆ $create_database

ilDatabaseSetupConfig::$create_database
protected

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

Referenced by __construct(), and getCreateDatabase().

◆ $database

ilDatabaseSetupConfig::$database
protected

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

Referenced by __construct(), and getDatabase().

◆ $host

ilDatabaseSetupConfig::$host
protected

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

Referenced by __construct(), and getHost().

◆ $password

ilDatabaseSetupConfig::$password
protected

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

Referenced by __construct(), and getPassword().

◆ $path_to_db_dump

ilDatabaseSetupConfig::$path_to_db_dump
protected

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

Referenced by __construct(), and getPathToDBDump().

◆ $port

ilDatabaseSetupConfig::$port
protected

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

Referenced by __construct(), and getPort().

◆ $type

ilDatabaseSetupConfig::$type
protected

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

Referenced by __construct(), and getType().

◆ $user

ilDatabaseSetupConfig::$user
protected

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

Referenced by __construct(), and getUser().

◆ DEFAULT_COLLATION

const ilDatabaseSetupConfig::DEFAULT_COLLATION = "utf8_general_ci"

Definition at line 10 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 11 of file class.ilDatabaseSetupConfig.php.

Referenced by __construct().


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