Packaged Events... am I doing this right?

Permalink
Ok... So I have a package that adds a new page type and I want to email a user when a page of this type is added, updated or deleted.

After reading through the available documentation I thought I found the way to do this... i.e:

Add...
public function on_start() {
   define('ENABLE_APPLICATION_EVENTS', TRUE);
   Events::extendPageType('new_page_type', 'on_page_add');
   Events::extendPageType('new_page_type', 'on_page_update');
   Events::extendPageType('new_page_type', 'on_page_delete');
}
...to my package's controller.php file and add...
public function on_page_add() {
   // Code here...
}
public function on_page_update() {
   // Code here...
}
public function on_page_delete() {
   // Code here...
}
...to the page type controller.php file.

However, this doesn't seem to work. What am I doing wrong?

ijessup
 
ijessup replied on at Permalink Reply
ijessup
Ahh... never mind, this is correct. I had the page type names camel cased instead of underscored.

DOH!
Mnkras replied on at Permalink Reply
Mnkras
also, you don't need the define if your doing it in a package i believe its only if you have a site_events.php
ijessup replied on at Permalink Reply
ijessup
Are you sure?

Though I could be not seeing something elsewhere, @line 113 in ~/concrete/libraries/events.php the fire() function states:
if ((!defined('ENABLE_APPLICATION_EVENTS')) || (ENABLE_APPLICATION_EVENTS == false)) {
   return;
}
My interpretation of that is, ENABLE_APPLICATION_EVENTS must be TRUE or it won't fire any events... regardless of whether or not it is part of a package.
ijessup replied on at Permalink Reply
ijessup
Thanks Mnkras!

Actually, as of 5.4 it not needed at all, it seems.
Mnkras replied on at Permalink Reply
Mnkras
You just need it if you use site_events.php

Pecked on mah new iPod :)