class_CompressorChannel.php
Go to the documentation of this file.00001 <?php
00024 class CompressorChannel extends BaseMiddleware implements Registerable {
00028 private $compressor = null;
00029
00035 protected function __construct () {
00036
00037 parent::__construct(__CLASS__);
00038 }
00039
00047 public final static function createCompressorChannel ($baseDir) {
00048
00049 $cInstance = new CompressorChannel();
00050
00051
00052 if (
00053 (is_null($cInstance->getCompressor()))
00054 || (!is_object($cInstance->getCompressor()))
00055 || (!method_exists($cInstance->getCompressor(), 'compressStream'))
00056 || (!method_exists($cInstance->getCompressor(), 'decompressStream'))
00057 ) {
00058
00059 $dirPointer = FrameworkDirectoryPointer::createFrameworkDirectoryPointer($baseDir);
00060
00061
00062 while ($dir = $dirPointer->readDirectoryExcept(array("..", ".", ".htaccess", ".svn"))) {
00063
00064 if ((substr($dir, 0, 6) == "class_") && (substr($dir, -4, 4) == ".php")) {
00065
00066
00067
00068 $className = substr($dir, 6, -4);
00069
00070
00071 $tempInstance = ObjectFactory::createObjectByName($className);
00072
00073
00074 $cInstance->setCompressor($tempInstance);
00075
00076
00077 break;
00078 }
00079 }
00080
00081
00082 $dirPointer->closeDirectory();
00083 }
00084
00085
00086 if (
00087 (is_null($cInstance->getCompressor()))
00088 || (!is_object($cInstance->getCompressor()))
00089 || (!method_exists($cInstance->getCompressor(), 'compressStream'))
00090 || (!method_exists($cInstance->getCompressor(), 'decompressStream'))
00091 ) {
00092
00093 $cInstance->setCompressor(ObjectFactory::createObjectByName('NullCompressor'));
00094 }
00095
00096
00097 return $cInstance;
00098 }
00099
00105 public final function getCompressor () {
00106 return $this->compressor;
00107 }
00108
00115 public final function setCompressor (Compressor $compressorInstance) {
00116 $this->compressor = $compressorInstance;
00117 }
00118
00122 public final function getCompressorExtension () {
00123
00124 return $this->getCompressor()->getCompressorExtension();
00125 }
00126 }
00127
00128
00129 ?>