Skip to content

Commit

Permalink
leftover merge conflicts
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/LiveUser/trunk@181042 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Arnaud Limbourg committed Feb 28, 2005
1 parent 213a5a2 commit 60d4785
Showing 1 changed file with 0 additions and 97 deletions.
97 changes: 0 additions & 97 deletions LiveUser.php
Expand Up @@ -1543,103 +1543,6 @@ function getStatus()
}

/**
<<<<<<< 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
Expand Down

0 comments on commit 60d4785

Please sign in to comment.