Observers: Introduction
An event based system to allow you to add behavior to specific events. When an event is observed the Orm will automatically call all the added observers to see if there's anything for them to do.
Orm is short for Object
Relational Mapper which does 2 things: it maps your database table rows to objects and it allows you
to establish relations between those objects.
It follows closely the
Active Record Pattern, but was also influenced by other systems.
An event based system to allow you to add behavior to specific events. When an event is observed the Orm will automatically call all the added observers to see if there's anything for them to do.
You can add observers in 2 ways: just add the name to have the observer called for all events or with
the observer as name and an array of specific events for which the observer is called.
When the Observer is in the same namespace as the Model and prefixed with Observer_ you can
leave out the "Observer_" prefix. In all other cases you have to provide the full classname.
class Model_Article
{
protected static $_observers = array(
'example', // will call Observer_Example class for all events
'Orm\\Observer_CreatedOn' => array(
'events' => array('before_insert'), // will only call Orm\Observer_CreatedOn at before_insert event
)
);
}