root/trunk/lib/SGL/Observer.php

Revision 2425 (checked in by demian, 1 month ago)

replaced tabs with spaces

Line 
1 <?php
2 class SGL_Observer
3 {
4     function update($observable) {}
5 }
6
7 class SGL_Observable
8 {
9     var $aObservers = array();
10
11     function attach($observer)
12     {
13         $this->aObservers[] = $observer;
14     }
15
16     function detach($observer)
17     {
18         $this->aObservers = array_diff($this->aObservers, array($observer));
19     }
20
21     function notify()
22     {
23         foreach ($this->aObservers as $obs) {
24             $returnVal = $obs->update($this);
25             if (PEAR::isError($returnVal)) {
26                 PEAR::raiseError($returnVal->getMessage(), $returnVal->getCode());
27             }
28         }
29     }
30
31     function getStatus() {}
32 }
33 ?>
Note: See TracBrowser for help on using the browser.