Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Twing;
- class observer
- {
- private $subscribers;
- public function dispatch($event)
- {
- foreach ($this->subscribers[$event] as $subscriber)
- call_user_func(array( $subscriber["object"] ,$subscriber["method"]));
- }
- public function subscribe($event, $object, $method)
- {
- foreach ($this->subscribers[$event] as $subscriber)
- if (($subsciber["object"] == $object) or ($subscriber["method"] == $method))
- return true; // Allready subscribed
- $this->subscribers[$event][] = array( "object" => $object,
- "method" => $method);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement