ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 CHATROOM_DATA_DIR = '/chatroom/'
 
const CHATROOM_CLIENT_CONFIG_FILENAME = 'client.cfg'
 
const 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.

References getClientFileContent(), and writeDataToFile().

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

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

Referenced by writeDataToFile().

95  : string
96  {
97  $path = ilFileUtils::getDataDir() . self::CHATROOM_DATA_DIR;
98 
99  if (!is_dir($path) && !ilFileUtils::makeDir($path)) {
100  throw new RuntimeException('Directory cannot be created');
101  }
102 
103  return $path;
104  }
$path
Definition: ltiservices.php:29
static getDataDir()
get data directory (outside webspace)
static makeDir(string $a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
+ 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.

References getServerFileContent(), and writeDataToFile().

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.
writeDataToFile(string $content, string $filename)
Writes $content to file named by $filename.
+ 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.

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

Referenced by createClientConfigFile().

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  }
global $DIC
Definition: shib_login.php:22
+ 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.

Referenced by createServerConfigFile().

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  }
+ 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.

References $path, and createDataDirIfNotExists().

Referenced by createClientConfigFile(), and createServerConfigFile().

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  }
$path
Definition: ltiservices.php:29
createDataDirIfNotExists()
Creates a data directory for configuration files, if the directory does not already exists...
$filename
Definition: buildRTE.php:78
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ CHATROOM_CLIENT_CONFIG_FILENAME

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

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

◆ CHATROOM_DATA_DIR

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

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

◆ CHATROOM_SERVER_CONFIG_FILENAME

const 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: