class_FilterChain.php

Go to the documentation of this file.
00001 <?php
00024 class FilterChain extends BaseFrameworkSystem {
00028         private $filters = array();
00029 
00035         protected function __construct () {
00036                 // Call parent constructor
00037                 parent::__construct(__CLASS__);
00038 
00039                 // Clean up a little
00040                 $this->removeNumberFormaters();
00041                 $this->removeSystemArray();
00042         }
00043 
00049         public final static function createFilterChain () {
00050                 // Get a new instance
00051                 $chainInstance = new FilterChain();
00052 
00053                 // Return the prepared instance
00054                 return $chainInstance;
00055         }
00056 
00063         public final function addFilter (Filterable $filterInstance) {
00064                 $this->filters[] = $filterInstance;
00065         }
00066 
00074         public function processFilters (Requestable $requestInstance, Responseable $responseInstance) {
00075                 // Run all filters
00076                 //* DEBUG */ echo "COUNT=".count($this->filters)."<br />\n";
00077                 foreach ($this->filters as $filterInstance) {
00078                         // Try to execute this filter
00079                         try {
00080                                 //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing started.<br />\n";
00081                                 $filterInstance->execute($requestInstance, $responseInstance);
00082                                 //* DEBUG */ echo "FILTER: ".$filterInstance->__toString().": Processing ended.<br />\n";
00083                         } catch (FilterChainException $e) {
00084                                 // This exception can be thrown to just skip any further processing
00085                                 break;
00086                         }
00087                 } // END - foreach
00088         }
00089 }
00090 
00091 // [EOF]
00092 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6