Uninstalling events

Permalink
Hi,

I'm working on a package that installs an event.
I have some questions about the events...

1.
When installing the package the event is also installed.
public function on_start() {
Events::extend('on_page_view', 'myClass', 'myMethod',  'packages/mypackage/models/myevent.php');
}

When using 5.4 or higher I don't need to add the ENABLE_APPLICATION_EVENTS to the config/site.php. But do I still have to add the Event::extend() to the config/site_event.php? Or does the function on_start do this for me?

2.
When testing my package I created the file config/site_event.php. But I wanted to disable my package for a while so I removed the site_event.php file, but the event was still running!? So do I need the file site_event.php or not? Or is this related to the version of C5?

3.
When uninstalling the package I need to uninstall the event al well... I can't seem to find the right code for doing this...

DeWebmakers
 
DeWebmakers replied on at Permalink Reply
DeWebmakers
I tried to edit my post (some writing errors), but I got "null" in the dilog window wehen clicking edit... Little bug in the new site?
olliephillips replied on at Permalink Best Answer Reply
olliephillips
Based on my recent foray into packaged events.

1) You do need Exent:extend() in the on_start method

2) Don't need this for packaged events 5.4 and newer

3) Events don't need to be uninstalled, they're only loaded at runtime. Removing the package will remove the any runtime events. Of course your package may do other things that do need uninstalling like creating new tables etc.

Hope that helps
DeWebmakers replied on at Permalink Reply
DeWebmakers
Great! Thanks.