00001 <?php 00025 class FileIoHandler extends BaseMiddleware { 00029 private $inputStream = null; 00030 00034 private $outputStream = null; 00035 00039 private static $thisInstance = null; 00040 00046 protected function __construct () { 00047 // Call parent constructor 00048 parent::__construct(__CLASS__); 00049 00050 // Set own instance 00051 self::$thisInstance = $this; 00052 } 00053 00060 public final static function createFileIoHandler () { 00061 // Get instance 00062 $ioHandler = new FileIoHandler(); 00063 00064 // Set the *real* file IO instances (both the same) 00065 $ioHandler->setInputStream(ObjectFactory::createObjectByConfiguredName('file_input_class')); 00066 $ioHandler->setOutputStream(ObjectFactory::createObjectByConfiguredName('file_output_class')); 00067 00068 // Return instance 00069 return $ioHandler; 00070 } 00071 00077 public final static function getInstance () { 00078 return self::$thisInstance; 00079 } 00080 00087 public final function setInputStream (FileInputStreamer $inputStream) { 00088 $this->inputStream = $inputStream; 00089 } 00090 00096 public final function getInputStream () { 00097 return $this->inputStream; 00098 } 00099 00106 public final function setOutputStream (FileOutputStreamer $outputStream) { 00107 $this->outputStream = $outputStream; 00108 } 00109 00115 public final function getOutputStream () { 00116 return $this->outputStream; 00117 } 00118 00127 public function saveFile ($fileName, $dataArray) { 00128 // Get output stream 00129 $outInstance = $this->getOutputStream(); 00130 00131 // Send the fileName and dataArray to the output handler 00132 $outInstance->saveFile($fileName, $dataArray); 00133 } 00134 00140 public function loadFileContents ($fqfn) { 00141 // Get output stream 00142 $inInstance = $this->getInputStream(); 00143 00144 // Read from the input handler 00145 return $inInstance->loadFileContents($fqfn); 00146 } 00147 } 00148 00149 // [EOF] 00150 ?>
1.5.6