cvs: pear /LiveUser LiveUser.php

From: Date: Mon, 28 Feb 2005 19:58:58 +0000
Subject: cvs: pear /LiveUser LiveUser.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-29935@lists.php.net to get a copy of this message
arnaud Mon Feb 28 14:58:58 2005 EDT Modified files: /pear/LiveUser LiveUser.php Log: leftover merge conflicts http://cvs.php.net/diff.php/pear/LiveUser/LiveUser.php?r1=1.55&r2=1.56&ty=u Index: pear/LiveUser/LiveUser.php diff -u pear/LiveUser/LiveUser.php:1.55 pear/LiveUser/LiveUser.php:1.56 --- pear/LiveUser/LiveUser.php:1.55 Mon Feb 28 14:52:24 2005 +++ pear/LiveUser/LiveUser.php Mon Feb 28 14:58:57 2005 @@ -40,7 +40,7 @@ * @author Bjoern Kraus <krausbn@php.net> * @copyright 2002-2005 Markus Wolff * @license http://www.gnu.org/licenses/lgpl.txt - * @version CVS: $Id: LiveUser.php,v 1.55 2005/02/28 19:52:24 arnaud Exp $ + * @version CVS: $Id: LiveUser.php,v 1.56 2005/02/28 19:58:57 arnaud Exp $ * @link http://pear.php.net/LiveUser */ @@ -1543,103 +1543,6 @@ } /** -<<<<<<< LiveUser.php -======= - * Add an observer object to listen to multiple events - * - * In contrast to LiveUser::attachObserver() this can be used to add - * an object providing observer methods for some or all events. - * If you don't set parameter $methods it tries to find matching methods - * for each registered event and adds them as observer callback. - * You can use the $methods parameter to set what method should act - * as an observer for what event. - * - * If you're only passing a function name, then you need to do as follows: - * <code> - * $function = 'foo'; - * $lu->attachObserver($function, array('event')); - * </code> - * - * Same goes if you have to pass a object instead of function name. - * - * @param object &$object object with observer methods - * @param mixed $methods optional used to change method names this way: - * array('event' => 'realMethodName', ...) or string - * @return bool true on success, otherwise false - * - * @access public - * @see LiveUser::triggerEvent - */ - function attachObserver(&$object, $methods = array()) - { - if (empty($methods)) { - foreach ($this->events as $event) { - if (method_exists($object, $event)) { - $methods[$event] = $event; - } - } - } elseif (is_string($methods)) { - $methods = array($methods => $methods); - } - - foreach ($methods as $event => $method) { - if (!isset($this->_observers[$event])) { - $this->_observers[$event] = array(); - } - - if (is_object($object)) { - $this->_observers[$event][] = array(&$object, $method); - } else { - $this->_observers[$event][] = $object; - } - } - - return true; - } - - /** - * Notify all attached observers about a certain event - * - * LiveUser object ($this) and $params are set as first and - * second parameters for each observer notification. - * $event is always set as 'event' field in $params, so this can - * not be used as a parameter but is useful if you want to use - * one single observer callback function for multiple events. - * - * @param string $event event name - * @param array $params optional params to send to observers - * @return bool true on success, false otherwise - * - * @access public - * @see LiveUser::attachObserver(), LiveUser::attachObserverObj(), LiveUser::registerEvent() - */ - function triggerEvent($event, $params = array()) - { - if (!isset($this->_observers[$event]) || empty($this->_observers[$event])) { - if ($GLOBALS['_LIVEUSER_DEBUG']) { - $this->_stack->push( - LIVEUSER_ERROR_UNKNOWN_EVENT, - 'notice', array('event' => $event), - 'no observer to notify for event ' . $event); - } - // it is no error if no observer was attached to handle an event, so - return true; - } - - $params['event'] = $event; - $success = true; - - $num = count($this->_observers[$event]); - for ($i = 0; $i < $num; $i++) { - if (is_callable($this->_observers[$event][$i])) { - $success = call_user_func($this->_observers[$event][$i], $this, $params); - } - } - return $success; - } - - /** ->>>>>>> 1.54 * make a string representation of the object * * @return string

« previous php.pear.cvs (#29935) next »