Implementing Oxwall OW_EventManager Class

OW_EventManager binds a function to Oxwall event system


The OW_EventManager class provides access to Oxwall event system of framework. Works as simple as it can be – plugins add PHP listeners (callbacks) to manager stack. When an event is triggered the whole stack is called.

An event is triggered using the trigger( OW_Event $event ) method, this returns an object of OW_Event.


For example purpose, we will create a method that creates user account and send a welcome message with OW_EventManager.

trigger( OW_Event $event )

This method triggers Oxwall event listeners and return an object of OW_Event.


  • $event
    OW_Event ( $name, array $params = array(), $dataValue = null )
    • (string|$name) (required)
    • (array|$params ) (required)
    • (mixed|$dataValue)(optional)


	* Method to save user
	public function saveUser( $username, $password, $email, $accountType )
		//Get instance of BOL_UserService
		$userService = BOL_UserService::getInstance();
		//Create user account. Returns BOL_User object
		$user = $userService->createUser( $username, $password, $email, $accountType );
		//Set new event parameters
		$event = new OW_Event('plugin_key_after_user_register', array(
			'userDto' => $user
		//Trigger an event for after registering user
		OW::getEventManager()->trigger($event );

bind( $name, $listener, $priority = null )

Binds listener to event. Callback should be valid PHP callback.


  • $name
    • (string|$name)
  • $listener
    • (callback|$listener)
  • $priority
    • (int|$priority)(optional)
    • Default: 1000


You should do this part from your event handler class or from your plugin init.php file.

	* Bind Event
	class PLUGINKEY_CLASS_EventHandler
		//Callback for sending welcome message
		public function sendUserWelcome( OW_Event $e )
			//Get event parameters
			$params = $e->getParams();
			//BOL_User object
			$user = $params['userDto'];
			//Send Welcome letter
		public function init()
			//bind sendUserWelcome() method to 'plugin_key_after_user_register' event
			OW::getEventManager()->bind('plugin_key_after_user_register', array($this, 'sendUserWelcome'));

Finally, you can initialize the event handler from your init.php file.

$eventHandler = new PLUGINKEY_CLASS_EventHandler();

unbind( $name, $listener )

Unbinds listener from event. Callback should be valid PHP callback.

One thought on “Implementing Oxwall OW_EventManager Class”

Leave a Reply