CakePower triggers lots of events while performing it’s logic so you can write some listeners and inject logic and code into altering the standard flow of the application.
This post describe each event triggered by CakePower, it’s properties and available returning values.
Understand CakePower Events:
Pretend you have Pizza plugin who order pizza for you then you write a NewPizza plugin who perform this task better but for sentimental reasons you don’t want to delete the original Pizza‘s plugin.
So, your NewPizza plugin needs a way to tell the app to stop listening at the old plugin!
// NewPizza/Config/bootstrap.php
function disableOriginalPizzaPlugin($e) {
if ( $e->data['_info']['name'] == 'Pizza' ) $e->result['skip'] = true;
}
CakeEventManager::instance()->attach( 'disableOriginalPizzaPlugin', 'CakePower.beforeLoadPlugin' );
The code above attach a piece of logic to the CakePower’s plugins autoload system and prevent the Pizza plugin to be loaded anymore. Obviously you need your NewPizza plugin to be loaded before the original Pizza! You can use the Config/plugin.php to perform this ordering issue!
CakePower.beforeLoadPlugin
Is triggered before CakePower loads each plugin. Receives the plugin’s information structure into $e->data property.
If you set $e->result['skip'] to a true value then CakePower skip the plugin.
There is no $e->subject() because this event is triggered from the bootstrap.php
CakePower.pluginsLoaded
Is triggered when all plugins are loaded.
No returning values are observed.
There is no $e->subject() because this event is triggered from the bootstrap.php







