_tolerateFailures = $tolerateFailures; } /** * Returns true when sub-filters can fail as long * as at least one filter returns a result. * @return boolean */ function getTolerateFailures() { return $this->_tolerateFailures; } // // Implementing abstract template methods from PersistentFilter // /** * @see PersistentFilter::getClassName() */ function getClassName() { return 'lib.pkp.classes.filter.GenericMultiplexerFilter'; } // // Implementing abstract template methods from Filter // /** * @see Filter::process() * @param $input mixed * @return array */ function &process(&$input) { // Iterate over all filters and return the results // as an array. $output = array(); foreach($this->getFilters() as $filter) { // Make a copy of the input so that the filters don't interfere // with each other. if (is_object($input)) { $clonedInput = clone($input); } else { $clonedInput = $input; } // Execute the filter $intermediateOutput =& $filter->execute($clonedInput); // Propagate errors of sub-filters (if any) foreach($filter->getErrors() as $errorMessage) $this->addError($errorMessage); // Handle sub-filter failure. if (is_null($intermediateOutput)) if ($this->getTolerateFailures()) { continue; } else { // No need to go on as the filter will fail // anyway out output validation so we better // safe time and return immediately. $output = null; break; } else { // Add the output to the output array. $output[] =& $intermediateOutput; } unset($clonedInput, $intermediateOutput); } // Fail in any case if all sub-filters failed. if (empty($output)) $output = null; return $output; } } ?>