Event API - Extend our Joomla extensions

The need to extend the functionality of an extension goes hand in hand with using Joomla. The current standard in dealing with this need is to try to use existing Joomla event triggers. This isn't bad, but maybe not as granular as you would like.

You might simply use the onAfterDispatch plugin event to re-execute a component with your own controller. But, there are performance implications to using an event trigger that may run the whole component before it’s able to fire. In some cases allowing normal application execution to the end can also be tricky.

Another option is to contact a respective extension's developer and ask them to add a new plugin event trigger. But this is far from ideal. The developer ends up with an extension that is peppered with hooks that they need to maintain and you need to remember. They become artifacts that need to be rediscovered over and over again.

DOCman & LOGman plugins

Therein lies some of the motivation and thought behind the design and implementation of Joomlatools extensions, and the underlying Joomlatools Framework.

How do you get to extend an extension's behavior at just the right spot? That's what our extensions provide you, out of the box. Observe an object's 'action' methods and fire events both before and after those methods are executed.

public function onBeforeDocmanDocumentControllerAdd(KEvent $event)
    // Do something nifty before a new document is added
public function onAfterDocmanDocumentControllerAdd(KEvent $event)
    // Do something nifty after a new document is added

This Event publisher and subscriber modeled architecture is made available through the Joomla Plugin API. Custom plugins follow the same general structural conventions as a core plugin, but with a method naming convention that allows for a very fine grained targeting.

We've written some great documentation about creating custom plugins for DOCman & LOGman. Or check the plugins documentation of our underlying framework.

Happy coding!

Written by

Tom Janssens

01 Jun 2016

Join 23000+ others and subscribe to our newsletter!