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.

Did you get the answer you were searching for?

Save hours of searching online or wasting money testing unnecessary plugins, get in touch with me and let's discuss a suitable plan for your project. Best thing about this service is that you are never placed on hold and get to talk to an expereinced Oxwall/Skadate developer.

Get Answers for Free!

Ask a question related to this topic and get immediate answers from other community members in 48hrs or less. Contribute by answering members questions.

Ask Question
Premium Service

Whether it's a custom plugin, theme or dedicated support needed to get you started on your project, get professional 24/7 support tailored to your need.

Get in Touch

Or just leave a comment...

Post Tags:

  • micexmc
  • tighti3l
  • whenc5w
  • yesterdayv2j

One thought on “Implementing Oxwall OW_EventManager Class”

Leave a Reply