ILIAS  trunk Revision v11.0_alpha-1843-g9e1fad99175
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 . 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.

References ilDBConstants\getAvailableCollations(), ilDBConstants\getInstallableTypes(), and ILIAS\Repository\user().

Referenced by toMockIniFile().

53  {
54  if (!in_array($type, \ilDBConstants::getInstallableTypes())) {
55  throw new \InvalidArgumentException(
56  "Unknown database type: $type"
57  );
58  }
59  if ($collation && !in_array(trim($collation), \ilDBConstants::getAvailableCollations())) {
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()
+ 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.

References $collation.

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

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

References $database.

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

◆ getHost()

ilDatabaseSetupConfig::getHost ( )

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

References $host.

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

◆ 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:30

◆ getPathToDBDump()

ilDatabaseSetupConfig::getPathToDBDump ( )

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

References $path_to_db_dump.

112  : string
113  {
114  return $this->path_to_db_dump;
115  }

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

References $type.

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

◆ getUser()

ilDatabaseSetupConfig::getUser ( )

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

References $user.

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

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

References __construct(), and null.

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__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...
+ 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 getCollation().

◆ $config

ilDatabaseSetupConfig ilDatabaseSetupConfig::$config

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

◆ $database

string ilDatabaseSetupConfig::$database
protected

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

◆ $path_to_db_dump

string ilDatabaseSetupConfig::$path_to_db_dump
protected

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

Referenced by getPathToDBDump().

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

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


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