From 3413fe6bfd423d45d083ff4ed62c0f72c2cc272f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 28 May 2009 06:11:53 +0800 Subject: Rename 'kohana' to 'system' to conform to the Kohana filesystem layout. I'm comfortable with us not clearly drawing the distinction about the fact that it's Kohana. Signed-off-by: Gallery Role Account --- system/libraries/Event_Subject.php | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 system/libraries/Event_Subject.php (limited to 'system/libraries/Event_Subject.php') diff --git a/system/libraries/Event_Subject.php b/system/libraries/Event_Subject.php new file mode 100644 index 00000000..d1ccc544 --- /dev/null +++ b/system/libraries/Event_Subject.php @@ -0,0 +1,67 @@ +listeners[spl_object_hash($obj)] = $obj; + + return $this; + } + + /** + * Detach an observer from the object. + * + * @chainable + * @param object Event_Observer + * @return object + */ + public function detach(SplObserver $obj) + { + // Remove the listener + unset($this->listeners[spl_object_hash($obj)]); + + return $this; + } + + /** + * Notify all attached observers of a new message. + * + * @chainable + * @param mixed message string, object, or array + * @return object + */ + public function notify($message) + { + foreach ($this->listeners as $obj) + { + $obj->notify($message); + } + + return $this; + } + +} // End Event Subject \ No newline at end of file -- cgit v1.2.3