In order to bootstrap your plugin as of Elgg 3.0 you can use a bootstrap class. This class must implement
\Elgg\PluginBootstrapInterface interface, but it’s recommended you extend the
class as some preparations have already been done.
If you only need a limited subset of the bootstrap functions your class can also extend the
this class already has all the functions of
\Elgg\PluginBootstrapInterface implemented. So you can overload only the functions you need.
You must register your bootstrap class in the
return [ // Bootstrap must implement \Elgg\PluginBootstrapInterface 'bootstrap' => MyPluginBootstrap::class, ];
Allows the plugin to require additional files, as well as configure services prior to booting the plugin.
Allows the plugin to register handlers for
system events, as
well as implement boot time logic.
Allows the plugin to implement business logic and register all other handlers.
Allows the plugin to implement logic after all plugins are initialized.
Allows the plugin to implement logic during shutdown.
This assumes your bootstrap class extends the
\Elgg\PluginBootstrap abstract class or the
Returns Elgg’s public DI container. This can be helpfull if you wish to register plugin hooks or event listeners.
$hooks = $this->elgg()->hooks; $hooks->registerHandler('register', 'menu:entity', 'my_custom_menu_callback'); $events = $this->elgg()->events; $events->registerHandler('create', 'object', MyCustomObjectHandler::class);