/** * Publish an event by calling all listeners that have registered to receive it. * * @param string|KEventInterface $event The event name or a KEventInterface object * @param array|Traversable $attributes An associative array or a Traversable object * @param KObjectInterface $target The event target * @return null|KEventInterface Returns the event object. If the chain is not enabled will return NULL. */ public function publishEvent($event, $attributes = array(), $target = null) { if ($this->isEnabled()) { //Make sure we have an event object if (!$event instanceof KEventInterface) { $event = new KEvent($event, $attributes, $target); } //Notify the listeners $listeners = $this->getListeners($event->getName()); foreach ($listeners as $listener) { $start = microtime(true); call_user_func($listener, $event, $this); $this->__profiles[] = array('message' => $event->getName(), 'period' => microtime(true) - $start, 'time' => microtime(true), 'memory' => $this->getMemoryUsage(), 'target' => $target instanceof KObjectInterface ? $target->getIdentifier() : $target, 'listener' => $listener); if (!$event->canPropagate()) { break; } } return $event; } else { $this->getDelegate()->publishEvent($event, $attributes, $target); } return null; }
/** * Check if the user is equal * * @param KObjectInterface|KUserInterface $user * @return Boolean */ public function equals(KObjectInterface $user) { if ($user instanceof KUserInterface) { if ($user->getEmail() == $this->getEmail()) { if ($user->getPassword() == $this->getPassword()) { return true; } } } return false; }