Not a developer? Go to


Creating Your Own Callbacks

In some circumstance a developer may wish to fire off an event of their own so that another part of their application can respond accordingly. To fire an event call run_callbacks on the primary MT instance. Pass to run_callbacks the name of the event people can register callbacks for, and any additional parameters that will be passed to the callback as arguments.

This is how you would fire an event:

package Example::Plugin;
use strict;

sub do_something {
    # the plugin is doing something
    my $result = MT->run_callbacks('CallbackName', $arg1, $arg2);
    # the plugin keeps doing something

And here is the registry entry for this callback:

    Example::Plugin::CallbackName: $Example::Example::Plugin::handler

And finally the event handler itself:

sub handler {
    my ($cb, $arg1, $arg2) = @_;
    # handle the event