I'm trying to add a new event to getEvents() method in my plugin. To my surprise the method is not called. I suspect that Blesta caches the data somewhere as a part of a plugin installation process.
Am I right? Or am I missing something?
<?php
class MyPluginPlugin extends Plugin {
...
public function getEvents() {
// THIS METHOD IS NOT CALLED. I CHECKED BY ADDING A LOGGING STATEMENT HERE.
return array(
array(
'event' => "Appcontroller.preAction",
'callback' => array("this", "run")
),
array(
'event' => "Another.event",
'callback' => array("this", "anotherEvent")
)
);
}
public function run($event) {
// This will execute when the "Appcontroller.preAction" event is triggered
}
}
?>
public function getEvents() {
return array(
array(
'event' => "Invoices.add",
'callback' => array("this", "invoiceAdded")
)
);
}
public function invoiceAdded($event)
{
\BlestaLogger::addDebug("plugins/my_plugin_plugin/Plugin::invoiceAdded(event)", [$event]);
\BlestaLogger::addDebug("plugins/my_plugin_plugin/Plugin::invoiceAdded(): TODO - call a method in NettAccounts model");
\BlestaLogger::addDebug("plugins/my_plugin_plugin/Plugin::invoiceAdded(-)");
}
Question
MartyIX
Hola,
I'm trying to add a new event to getEvents() method in my plugin. To my surprise the method is not called. I suspect that Blesta caches the data somewhere as a part of a plugin installation process.
Am I right? Or am I missing something?
Thanks!
EDIT: I tried my idea with installation of the plugin and the method was really called. So that seems to be the culprit.
EDIT2: I could have just have a look at plugin_manager.php file...
EDIT3: This seems to work:
Event registration in /plugins/my_plugin_name/my_plugin_plugin.php (see http://docs.blesta.com/display/dev/Plugin+Events):
Sample controller /plugins/my_plugin_name/Controllers/InvoiceTester.php:
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.