The PxEvent Class
PxEvent: Information about a event fired by a subject
Base event class that holds all event information.
When you want to trigger an event, you can create an instance of this class and call the fireEvent() method on
the object that fires the event. This fireEvent() method should then take care of notifying all observers.
Each event has a name, it is best to use very descriptive names for the event names, like 'user_created',
'emailing_sent', et cetera.
You can extend this event class if you want to store additional information in an event object, or add extra
methods to the object. For example, if you want to fire an event when an e-mail address was changed, you can
extend the PxEvent class to create your own EmailEvent event that adds extra methods oldEmailAddress() and
newEmailAddress() to the object.
When you want to trigger an event, you can create an instance of this class and call the fireEvent() method on
the object that fires the event. This fireEvent() method should then take care of notifying all observers.
Each event has a name, it is best to use very descriptive names for the event names, like 'user_created',
'emailing_sent', et cetera.
You can extend this event class if you want to store additional information in an event object, or add extra
methods to the object. For example, if you want to fire an event when an e-mail address was changed, you can
extend the PxEvent class to create your own EmailEvent event that adds extra methods oldEmailAddress() and
newEmailAddress() to the object.
Synopsis
Class PxEvent
Methods
Examples
Example
Extend the PxEvent object example.
A extender of the PxEventSubject should fire this event by providing a
stdClass with the members old and new containing the e-mail addresses.
class EmailAddressChangeEvent extends PxEvent
{
// Return the new e-mail address
public function newEmailAddress()
{
return $this->data->new;
}
// Return the old e-mail address
public function oldEmailAddress()
{
return $this->data->old;
}
}
