Page 1 of 1

Event in plugin A not usable in plugin B

Posted: 08 Jul 2013, 15:14
by kelson
Hi,

I would like to know how to declare a new plugin event in order to use it in another plugin without dependency ?

I try this way :

Plugin A :
class APlugin extends MantisPlugin {
function events(){
return array(
'EVENT_A' => EVENT_TYPE_OUTPUT,
);
}
}

Plugin B :
class BPlugin extends MantisPlugin {
function hooks(){
return array(
'EVENT_A' => 'test',
);
}

function test(){
echo 'Awesome !';
}
}

But I had this message :
APPLICATION WARNING #2400: Event "EVENT_A" has not yet been declared.

If I declare a dependency in plugin B, it work correctly :
class BPlugin extends MantisPlugin {
$this->requires = array(
'MantisCore' => '1.2.0',
'A' => '1.0',
);

...
}

I think I am not using the right way to declare a plugin event, could some let me know how to do that properly ?!

Thanks.