/** * Receive update from subject * * @param SplSubject $subject Subject observed that contains event to write * * @return void */ public function update(SplSubject $subject) { $this->subject = $subject; $event = $subject->getEvent(); // delegate to right event implementation call_user_func(array($this, $event->getName()), $event); }
/** * Receive update from subject * * @param SplSubject $subject Subject observed that contains event to write * * @return void */ public function update(SplSubject $subject) { $this->subject = $subject; $event = $subject->getEvent(); // delegate to right event implementation $data = call_user_func(array($this, $event->getName()), $event); error_log(sprintf('%s [%s] %s %s', strftime($this->timeFormat, $data['timestamp']), $data['level'], $data['message'], PHP_EOL), 3, $this->destFile); }
/** * Receive update from subject * * @param SplSubject $subject Subject observed that contains event to write * * @return void */ public function update(SplSubject $subject) { $this->subject = $subject; $event = $subject->getEvent(); // delegate to right event implementation $data = call_user_func(array($this, $event->getName()), $event); if (empty($data)) { return; } $this->growl->publish($data['name'], $data['title'], $data['description'], $data['options']); }
/** * Method to trigger events. * The method first generates the even from the argument array. Then it unsets the argument * since the argument has no bearing on the event handler. * If the method exists it is called and returns its return value. If it does not exist it * returns null. * * @param array &$args Arguments * * @return mixed Routine return value */ public function update(SplSubject $subject) { // get the event and args from the subject (dispatcher) to use in the plugin $event = $subject->getEvent(); $args = $subject->getArgs(); /* * If the method to handle an event exists, call it and return its value * If it does not exist, return null. */ if (method_exists($this, $event)) { return call_user_func_array(array($this, $event), $args); } else { return null; } }