Call us: 0031 23-75-10500  |  Language: Dutch English German
 
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.

Synopsis


Class PxEvent

Methods

public PxEvent::__construct ( PxEventSubject $subject , string $name , [mixed $data = NULL] )
public mixed PxEvent::data ( void )
public string PxEvent::name ( void )
public mixed PxEvent::returnValue ( void )
public PxEvent PxEvent::stop ( void )
public boolean PxEvent::stopped ( void )

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;
    }
}