abstract class RulesEventHandlerBase in Rules 7.2
Base class for event handler.
Hierarchy
- class \RulesEventHandlerBase implements RulesEventHandlerInterface
Expanded class hierarchy of RulesEventHandlerBase
File
- includes/
rules.event.inc, line 180 - Contains event handler interface and base classes.
View source
abstract class RulesEventHandlerBase implements RulesEventHandlerInterface {
/**
* The event name.
*
* @var string
*/
protected $eventName;
/**
* The event info.
*
* @var array
*/
protected $eventInfo;
/**
* The event settings.
*
* @var array
*/
protected $settings = array();
/**
* Implements RulesEventHandlerInterface::__construct().
*/
public function __construct($event_name, $info) {
$this->eventName = $event_name;
$this->eventInfo = $info;
$this->settings = $this
->getDefaults();
}
/**
* Implements RulesEventHandlerInterface::getSettings().
*/
public function getSettings() {
return $this->settings;
}
/**
* Implements RulesEventHandlerInterface::setSettings().
*/
public function setSettings(array $settings) {
$this->settings = $settings + $this
->getDefaults();
return $this;
}
/**
* Implements RulesEventHandlerInterface::validate().
*/
public function validate() {
// Nothing to check by default.
}
/**
* Implements RulesEventHandlerInterface::extractFormValues().
*/
public function extractFormValues(array &$form, array &$form_state) {
foreach ($this
->getDefaults() as $key => $setting) {
$this->settings[$key] = isset($form_state['values'][$key]) ? $form_state['values'][$key] : $setting;
}
}
/**
* Implements RulesEventHandlerInterface::availableVariables().
*/
public function availableVariables() {
return isset($this->eventInfo['variables']) ? $this->eventInfo['variables'] : array();
}
/**
* Implements RulesEventHandlerInterface::getEventName().
*/
public function getEventName() {
return $this->eventName;
}
/**
* Implements RulesEventHandlerInterface::getEventInfo().
*/
public function getEventInfo() {
return $this->eventInfo;
}
}