| 1 | <?php defined('SYSPATH') or die('No direct access allowed.'); |
||
| 12 | abstract class Event_Observer implements SplObserver |
||
| 13 | { |
||
| 14 | |||
| 15 | // Calling object |
||
| 16 | protected $caller; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Initializes a new observer and attaches the subject as the caller. |
||
| 20 | * |
||
| 21 | * @param object Event_Subject |
||
| 22 | * @return void |
||
|
|
|||
| 23 | */ |
||
| 24 | public function __construct(SplSubject $caller) |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Updates the observer subject with a new caller. |
||
| 32 | * |
||
| 33 | * @chainable |
||
| 34 | * @param object Event_Subject |
||
| 35 | * @return Event_Observer |
||
| 36 | */ |
||
| 37 | public function update(SplSubject $caller) |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Detaches this observer from the subject. |
||
| 51 | * |
||
| 52 | * @chainable |
||
| 53 | * @return Event_Observer |
||
| 54 | */ |
||
| 55 | public function remove() |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Notify the observer of a new message. This function must be defined in |
||
| 65 | * all observers and must take exactly one parameter of any type. |
||
| 66 | * |
||
| 67 | * @param mixed message string, object, or array |
||
| 68 | * @return void |
||
| 69 | */ |
||
| 70 | abstract public function notify($message); |
||
| 71 | } // End Event Observer |
||
| 72 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.