From: Roland Haeder Date: Wed, 14 May 2014 19:39:18 +0000 (+0200) Subject: Don't call the class' factory method directly, use ObjectFactory and X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5c2c855827d5dc90b825d1c88c9aeb76939024d0;p=core.git Don't call the class' factory method directly, use ObjectFactory and createObjectByConfiguredName() instead. This makes reimplementing classes much easier. Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/console/class_ConsoleTools.php b/inc/classes/main/console/class_ConsoleTools.php index 98d6ec4b..32746b47 100644 --- a/inc/classes/main/console/class_ConsoleTools.php +++ b/inc/classes/main/console/class_ConsoleTools.php @@ -207,13 +207,13 @@ class ConsoleTools extends BaseFrameworkSystem { try { // Get a file pointer - $io = FrameworkFileInputPointer::createFrameworkFileInputPointer($helperInstance->getConfigInstance()->getConfigEntry('hostname_file')); + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', $helperInstance->getConfigInstance()->getConfigEntry('hostname_file')); // Read the file - $rawData = trim($io->readFromFile()); + $rawData = trim($fileInstance->readFromFile()); // Close the file - $io->closeFile(); + $fileInstance->closeFile(); // Extract hostname from it $hostname = $helperInstance->extractHostnameFromRawData($rawData); diff --git a/inc/classes/main/io/io_handler/class_FileIoStream.php b/inc/classes/main/io/io_handler/class_FileIoStream.php index 35d00edd..d8cd5803 100644 --- a/inc/classes/main/io/io_handler/class_FileIoStream.php +++ b/inc/classes/main/io/io_handler/class_FileIoStream.php @@ -79,7 +79,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil for ($idx = 0; $idx < 5; $idx++) { // Get a file output pointer try { - $fileInstance = FrameworkFileOutputPointer::createFrameworkFileOutputPointer($fileName, 'w'); + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_output_class', $fileName); } catch (FileIoException $e) { // Create missing directory $dirName = dirname($fileName); @@ -147,7 +147,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil $readData = ''; // This will contain our read data // Get a file input handler - $fileInstance = FrameworkFileInputPointer::createFrameworkFileInputPointer($fqfn); + $fileInstance = ObjectFactory::createObjectByConfiguredName('file_raw_input_class', $fqfn); // Read all it's contents (we very and transparently decompress it below) while ($readRawLine = $fileInstance->readFromFile()) { diff --git a/inc/config.php b/inc/config.php index ba05848d..b828bb1a 100644 --- a/inc/config.php +++ b/inc/config.php @@ -359,5 +359,14 @@ $cfg->setConfigEntry('database_cache_enabled', FALSE); // CFG: DIRECTORY-CLASS $cfg->setConfigEntry('directory_class', 'FrameworkDirectoryPointer'); +// CFG: FILE-INPUT-CLASS +$cfg->setConfigEntry('file_raw_input_class', 'FrameworkFileInputPointer'); + +// CFG: FILE-OUTPUT-CLASS +$cfg->setConfigEntry('file_raw_output_class', 'FrameworkFileOutputPointer'); + +// CFG: FILE-INPUT-OUTPUT-CLASS +$cfg->setConfigEntry('file_raw_input_output_class', 'FrameworkFileInputOutputPointer'); + // [EOF] ?>