<?php
/**
* Abstract event handler.
* This class sets the base of custom event handler.
* These handlers are the event filters - if they accept the event, then will export it
*
*
* @author Marius Zadara <marius@zadara.org>
* @category org.zadara.marius.logger.classes
* @copyright (C) 2008 Marius Zadara <marius@zadara.org>
* @license GNU GPL
* @package org.zadara.marius.logger
* @abstract
*
*/
abstract class EventHandler
{
/**
* Unique id of the event handler
* @access protected
*/
protected $uniqueId;
/**
* Event handler exporter.
* On this exporter the export function will be called
* if the event has been accepted.
*
* @access protected
*/
protected $eventExporter;
/**
* Default constructor.
* It sets the values of the fields.
*
* @access public
* @param String $uniqueId Unique id of the handler
* @return EventHandler
*/
public function EventHandler($uniqueId = null)
{
// set the event exporter
$this->eventExporter = null;
// and the unique id
$this->uniqueId = is_null($uniqueId) ? uniqid() : $uniqueId;
}
/**
* Definition of the function that accepts the event.
* The body of this function will be set into the custom event handlers
* based on this class. In this function you can define any kind of rules
* that will accept or reject the event
*
* @access public
* @param Event $event The new event to be accepted - or not
* @return boolean
*/
public abstract function isEventAccepted($event);
/**
* Handler unique id getter
* @access public
* @final
*/
public final function getUniqueId()
{
return $this->uniqueId;
}
/**
* Function to set the handler's exporter.
* This object will be used to export the event.
*
* @param EventExporter $exporter The exporter object
* @see EventExporter
* @final
* @access public
*/
public final function setExporter($exporter)
{
if ($this->eventExporter != null)
return;
$this->eventExporter = $exporter;
}
/**
* Function to get the event handler's exporter object.
*
* @access public
* @final
* @return eventExporter
*/
public final function getExporter()
{
return $this->eventExporter;
}
}
?>
|