Don't call the class' factory method directly, use ObjectFactory and
authorRoland Haeder <roland@mxchange.org>
Wed, 14 May 2014 19:39:18 +0000 (21:39 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 14 May 2014 19:39:18 +0000 (21:39 +0200)
createObjectByConfiguredName() instead. This makes reimplementing classes much
easier.

Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/main/console/class_ConsoleTools.php
inc/classes/main/io/io_handler/class_FileIoStream.php
inc/config.php

index 98d6ec4..32746b4 100644 (file)
@@ -207,13 +207,13 @@ class ConsoleTools extends BaseFrameworkSystem {
 
                try {
                        // Get a file pointer
 
                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
 
                        // Read the file
-                       $rawData = trim($io->readFromFile());
+                       $rawData = trim($fileInstance->readFromFile());
 
                        // Close the file
 
                        // Close the file
-                       $io->closeFile();
+                       $fileInstance->closeFile();
 
                        // Extract hostname from it
                        $hostname = $helperInstance->extractHostnameFromRawData($rawData);
 
                        // Extract hostname from it
                        $hostname = $helperInstance->extractHostnameFromRawData($rawData);
index 35d00ed..d8cd580 100644 (file)
@@ -79,7 +79,7 @@ class FileIoStream extends BaseFrameworkSystem implements FileInputStreamer, Fil
                for ($idx = 0; $idx < 5; $idx++) {
                        // Get a file output pointer
                        try {
                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);
                        } 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
                $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()) {
 
                // Read all it's contents (we very and transparently decompress it below)
                while ($readRawLine = $fileInstance->readFromFile()) {
index ba05848..b828bb1 100644 (file)
@@ -359,5 +359,14 @@ $cfg->setConfigEntry('database_cache_enabled', FALSE);
 // CFG: DIRECTORY-CLASS
 $cfg->setConfigEntry('directory_class', 'FrameworkDirectoryPointer');
 
 // 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]
 ?>
 // [EOF]
 ?>