Listening to events

First create a class within jadu/custom that implements the JaduFramework\Event\Interfaces\InterfaceEvent.

    use JaduFramework\Event\Interfaces\InterfaceEvent;
    use JaduFramework\Event\Interfaces\InterfaceObject;

    class Jadu_Custom_MyCustomEvent implements InterfaceEvent
    {
        public function run(InterfaceObject $object)
        {
            // add logic
        }

        public function name()
        {
            // return the name of the event which you are going to listen for
            // example documentpage.save
        }
    }

The run method contains your logic. The method takes one parameter which is an InterfaceObject that is populated with data that is relevant to that event that is being listened out for.

For example, the documentpage.save event will return a Jadu_Document_Event_Object that is populated with a DocumentPage instance. You now have enough information to act upon this change.

The last part required is to register your new listener so the Jadu knows how to handle your custom Event. For custom work, we recommend the following:

  • Register your event within config/events.xml

This requires you to add the name of your class and the the event you are listening for:

    <item key="documentpage.save">Jadu_Custom_MyCustomEvent</item>

results matching ""

    No results matching ""