* */ abstract class ems_alert_conditionbase extends ems_alert_base implements ems_alert_interface_condition { /** * This is a string that defines the message to be put into the condition result object. It is setup in an sprintf string and uses an array of values for string replacement. * * @var string * @access protected */ protected $messageTemplate; /** * This is a collection of condition result objects * * @var libraries_collection * @access protected */ protected $conditionResults; /** * Constructor method that initiates the construction of the condition instance. This can't be overridden. * * @param ems_framework_registry $param * @access public * @return void */ final public function __construct(ems_framework_registry $param) { parent::__construct($param); $this->setDefaultValues(); } /** * Configures the object * * @param none * @access private * @return void */ private function setDefaultValues() { $this->messageTemplate = ""; $this->conditionResults = $this->param->factory->system->createCollection(); $this->configureCondition(); } /** * This method will conduct the test the condition is designed to perform and returns a boolean. * True means the condition is true and a conditionresult is generated. * False means the condition is false and no conditionresult will be generated * * @param none * @access public * @return boolean */ public function performCheck() { if (!$this->config) $this->setConfig($this->createConfig()); // this call does the actual check and if a condition match is found, then a condition result object is created with the method call // addResult $this->doPerformCheck(); if ($this->conditionResults->count() > 0) { return true; } else { return false; } } /** * This method will return a collection of condition results, generated from the condition processing * * @param none * @access public * @return libraries_collection */ public function getResults() { return $this->conditionResults; } /** * This method takes an array of message values (that are used in sprintf) and a reference object and creates a condition result object and adds it to the condition result collection * * @param array, reference object * @access protected * @return void */ protected function addResult($values,$obj = null) { $conditionResult = $this->param->factory->alert->createConditionResult($this,$values); $conditionResult->setRelevantObj($obj); $this->conditionResults->addItem($conditionResult); } /** * This method returns the message template that can be used in a condition result object. This is mainly for overriding the default message if desired. * * @param none * @access protected * @return string */ public function getMessageTemplate() { return $this->messageTemplate; } /** * This method sets the message template to be used in the condition result object. This is for overriding the default message. * * @param string * @access protected * @return void */ public function setMessageTemplate($value) { $this->messageTemplate = ""; if ($value) $this->messageTemplate = $value; } /** * This abstract method does the initial configuration of the condition object. * * @param none * @access protected * @return void */ abstract protected function configureCondition(); /** * This abstract method does the condition processing for the condition object. The extending class defines this functionality. * * @param none * @access protected * @return void */ abstract protected function doPerformCheck(); } ?>