ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 . 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.

References $collation, $create_database, $password, $path_to_db_dump, $port, $type, ilDBConstants\getAvailableCollations(), ilDBConstants\getInstallableTypes(), and user().

Referenced by toMockIniFile().

68  {
69  if (!in_array($type, \ilDBConstants::getInstallableTypes())) {
70  throw new \InvalidArgumentException(
71  "Unknown database type: $type"
72  );
73  }
74  if ($collation && !in_array(trim($collation), \ilDBConstants::getAvailableCollations())) {
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()
+ 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.

References $collation.

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

◆ getCreateDatabase()

ilDatabaseSetupConfig::getCreateDatabase ( )

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

References $create_database.

110  : bool
111  {
112  return $this->create_database;
113  }

◆ getDatabase()

ilDatabaseSetupConfig::getDatabase ( )

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

References $database.

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

◆ getHost()

ilDatabaseSetupConfig::getHost ( )

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

References $host.

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

◆ getPassword()

ilDatabaseSetupConfig::getPassword ( )

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

References $password.

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

◆ getPathToDBDump()

ilDatabaseSetupConfig::getPathToDBDump ( )

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

References $path_to_db_dump.

130  : string
131  {
132  return $this->path_to_db_dump;
133  }

◆ getPort()

ilDatabaseSetupConfig::getPort ( )

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

References $port.

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

◆ getType()

ilDatabaseSetupConfig::getType ( )

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

References $type.

◆ getUser()

ilDatabaseSetupConfig::getUser ( )

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

References $user.

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

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

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

References $config, and __construct().

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_varname'"
172  );
173  }
174  }
175  public function __construct(\ilDatabaseSetupConfig $config)
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  }
__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)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
INIFile Parser.
+ 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 getDatabase().

◆ $host

ilDatabaseSetupConfig::$host
protected

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

Referenced by 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 getUser().

◆ DEFAULT_COLLATION

const ilDatabaseSetupConfig::DEFAULT_COLLATION = "utf8_general_ci"

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

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


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