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

Public Member Functions

 createClientConfigFile (array $settings)
 Creates a client config file and saves it to the chatroom data directory. More...
 
 createServerConfigFile (array $settings)
 Creates a server config file and saves it to the chatroom data directory. More...
 

Protected Member Functions

 getClientFileContent (array $settings)
 Get the client config file content as json encoded string. More...
 
 writeDataToFile (string $content, string $filename)
 Writes $content to file named by $filename. More...
 
 createDataDirIfNotExists ()
 Creates a data directory for configuration files, if the directory does not already exists. More...
 
 getServerFileContent (array $settings)
 Get the server config file contetn as json encoded string. More...
 

Private Attributes

const string CHATROOM_DATA_DIR = '/chatroom/'
 
const string CHATROOM_CLIENT_CONFIG_FILENAME = 'client.cfg'
 
const string CHATROOM_SERVER_CONFIG_FILENAME = 'server.cfg'
 

Detailed Description

Definition at line 28 of file class.ilChatroomConfigFileHandler.php.

Member Function Documentation

◆ createClientConfigFile()

ilChatroomConfigFileHandler::createClientConfigFile ( array  $settings)

Creates a client config file and saves it to the chatroom data directory.

Exceptions
Exception

Definition at line 38 of file class.ilChatroomConfigFileHandler.php.

38 : void
39 {
40 $content = $this->getClientFileContent($settings);
41 $this->writeDataToFile($content, self::CHATROOM_CLIENT_CONFIG_FILENAME);
42 }
writeDataToFile(string $content, string $filename)
Writes $content to file named by $filename.
getClientFileContent(array $settings)
Get the client config file content as json encoded string.

References getClientFileContent(), and writeDataToFile().

+ Here is the call graph for this function:

◆ createDataDirIfNotExists()

ilChatroomConfigFileHandler::createDataDirIfNotExists ( )
protected

Creates a data directory for configuration files, if the directory does not already exists.

Exceptions
RuntimeExceptionThrows Exception if data dir creation failed

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

95 : string
96 {
98
99 if (!is_dir($path) && !ilFileUtils::makeDir($path)) {
100 throw new RuntimeException('Directory cannot be created');
101 }
102
103 return $path;
104 }
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getDataDir()
get data directory (outside webspace)
$path
Definition: ltiservices.php:30

References $path, CHATROOM_DATA_DIR, ilFileUtils\getDataDir(), and ilFileUtils\makeDir().

Referenced by writeDataToFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createServerConfigFile()

ilChatroomConfigFileHandler::createServerConfigFile ( array  $settings)

Creates a server config file and saves it to the chatroom data directory.

Exceptions
Exception

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

110 : void
111 {
112 $content = $this->getServerFileContent($settings);
113 $this->writeDataToFile($content, self::CHATROOM_SERVER_CONFIG_FILENAME);
114 }
getServerFileContent(array $settings)
Get the server config file contetn as json encoded string.

References getServerFileContent(), and writeDataToFile().

+ Here is the call graph for this function:

◆ getClientFileContent()

ilChatroomConfigFileHandler::getClientFileContent ( array  $settings)
protected

Get the client config file content as json encoded string.

Definition at line 47 of file class.ilChatroomConfigFileHandler.php.

47 : string
48 {
49 global $DIC;
50
51 // Dirty configuration swap: Ilias differentiates between InnoDB and MyISAM.
52 // MyISAM is configured as mysql, InnoDB as innodb.
53 // The client config file only needs information about driver not engine
54 $type = $DIC['ilClientIniFile']->readVariable('db', 'type');
55 if (in_array($type, [
58 ''
59 ], true)) {
60 $type = 'mysql';
61 }
62
63 $settings['database'] = [
64 'type' => $type,
65 'host' => $DIC['ilClientIniFile']->readVariable('db', 'host'),
66 'port' => (int) $DIC['ilClientIniFile']->readVariable('db', 'port'),
67 'name' => $DIC['ilClientIniFile']->readVariable('db', 'name'),
68 'user' => $DIC['ilClientIniFile']->readVariable('db', 'user'),
69 'pass' => $DIC['ilClientIniFile']->readVariable('db', 'pass')
70 ];
71
72 return json_encode($settings, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
73 }
readVariable(string $a_group, string $a_var_name)
reads a single variable from a group
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\int(), readVariable(), ilDBConstants\TYPE_INNODB, and ilDBConstants\TYPE_MYSQL.

Referenced by createClientConfigFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getServerFileContent()

ilChatroomConfigFileHandler::getServerFileContent ( array  $settings)
protected

Get the server config file contetn as json encoded string.

Definition at line 119 of file class.ilChatroomConfigFileHandler.php.

119 : string
120 {
121 unset($settings['ilias_proxy'], $settings['client_proxy'], $settings['ilias_url'], $settings['client_url']);
122
123 return json_encode($settings, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
124 }

Referenced by createServerConfigFile().

+ Here is the caller graph for this function:

◆ writeDataToFile()

ilChatroomConfigFileHandler::writeDataToFile ( string  $content,
string  $filename 
)
protected

Writes $content to file named by $filename.

Exceptions
RuntimeException

Definition at line 79 of file class.ilChatroomConfigFileHandler.php.

79 : void
80 {
82 $handle = fopen($path . $filename, 'wb');
83
84 if (!fwrite($handle, $content)) {
85 throw new RuntimeException('Cannot write to file');
86 }
87
88 fclose($handle);
89 }
$filename
Definition: buildRTE.php:78
createDataDirIfNotExists()
Creates a data directory for configuration files, if the directory does not already exists.

References $filename, $path, and createDataDirIfNotExists().

Referenced by createClientConfigFile(), and createServerConfigFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ CHATROOM_CLIENT_CONFIG_FILENAME

const string ilChatroomConfigFileHandler::CHATROOM_CLIENT_CONFIG_FILENAME = 'client.cfg'
private

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

◆ CHATROOM_DATA_DIR

const string ilChatroomConfigFileHandler::CHATROOM_DATA_DIR = '/chatroom/'
private

Definition at line 30 of file class.ilChatroomConfigFileHandler.php.

Referenced by createDataDirIfNotExists().

◆ CHATROOM_SERVER_CONFIG_FILENAME

const string ilChatroomConfigFileHandler::CHATROOM_SERVER_CONFIG_FILENAME = 'server.cfg'
private

Definition at line 32 of file class.ilChatroomConfigFileHandler.php.


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