Observer

Intent
When an object changes, notify all interested parties
Motivation
events, synchronisation, ...
Implementation
Use hooks pattern at and after to implement the observer
No implementation needed in the Subject class
Example

//initialisation
$hs = new hooks();
$observer = new interested_party();
$change_method = array($object, 'setter');

//setup change point(can be done externally from $change method)
$hs->at('change', $change_method);

//express interest
$hs->after('change', array($obesrver, 'callback'));

$hs->run($arg);
Note
The precise implementation of the hooks may differ, depending on functionality, abstraction, sugar, ... Have a look at the drupal hooks as well.
Powered by Drupal, an open source content management system