Hadise is very simple event management library for event driven applications.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
demos
library/Hadise
.gitignore
README.md

README.md

Hadise

Hadise is very simple a event management library. You can use this library easily as bellow.

Usage:

Hello World Listener:

use \Hadise\IEventListener;
use \Hadise\Event;

class HelloWorldListener implements IEventListener
{
	public function invoke(Event $event)
	{
		echo "Hello World " . PHP_EOL;
		var_dump($event->getParameters());
	}
}

Adding Event Listener

use \Hadise\EventManager;

EventManager::getManager('myApp')->addListener('OnHelloWorld', new HelloWorldListener());

Fireing Event

use \Hadise\EventManager;

EventManager::getManager('myApp')->riseEvent('OnHelloWorld', null, array('param1' => 2, 'param2' => 'hello world'));

Reference:

Name Type Description
EventManager Class Manages application events.
Event Class This class is sent as parameter to listener
IEventListener Interface Interface for Event Listeners

EventManager Class

Methods of EventManager:

Method Return Description
getManager EventManager returns event manager of the specified application.
addListener void add event listener to collection of event manager.
riseEvent void Triggers the specified event

getManager Method:

EventManager|returns event manager of the specified application.

Syntax:

EventManager getManager(string $app)

Parameters:

Parameter Type Description
$app string sapplication name of event manager.

addListener Method:

add event listener to collection of event manager.

Syntax:

void addListener(string $eventName, IEventListener $listener)

Parameters:

Parameter Type Description
$eventName string event name
$listener IEventListener Event listener object.

riseEvent Method:

Triggers the specified event

Syntax:

void riseEvent(string $eventName, object $source, array $parameters)

Parameters:

Parameter Type Description
$eventName string event name
$source object event source.
parameters array parameters of event (miscellaneous data.)

Event Class

Methods of Event:

Method Return Description
__construct void class constructor
getName string returns event name.
getSource object returns event source
getParameters array returns parameters on event

__construct Method:

class constructor

Syntax:

void __construct(string $eventName, object $source, array $parameters)

Parameters:

Parameter Type Description
$eventName string event name.
$source object source of event.
$parameters array parameters on event

getName Method:

returns event name.

Syntax:

string getName()

getSource Method:

returns event source

syntax:

object getSource()

getParameters Method:

returns parameters on event

Syntax:

array getParameters())

IEventListener Interface

Methods of IEventListener:

Method Return Description
invoke void callback function of event listener.

invoke Method:

callback function of event listener.

Syntax:

void invoke(Event $event)

Parameters:

Parameter Type Description
$event Event Event object of fired event.