topleft topright

Welcome, Guest. Please login or register.
June 19, 2013, 01:36:04 PM
Home Help Search Login Register
News: ATTENTION: Spambots must die! Humans must visit http://contact.futurescale.com to request forum access.

Pages: [1]
Print
Author Topic: notifyObservers edit suggested  (Read 1127 times)
saad
Full Member
***
Posts: 21


View Profile Email
« on: May 07, 2012, 12:59:52 AM »

Should be
  if (isset($this->observerMap[ $notification->getName() ]) && $this->observerMap[ $notification->getName() ] != null)
    ... 
  }

instead of
  if ($this->observerMap[ $notification->getName() ] != null) { //causes Notice: Undefined index:  (appearing if you send a notification inside a command)
    ...
  }

just like the way it's coded for registerObservers.

public function registerObserver( $notificationName, IObserver $observer ) {
  if (isset($this->observerMap[ $notificationName ]) && $this->observerMap[ $notificationName ] != null) {
    array_push( $this->observerMap[ $notificationName ], $observer );
  } else {
    $this->observerMap[ $notificationName ] = array( $observer );
  }
}
« Last Edit: May 07, 2012, 01:06:21 AM by saad » Logged
Pages: [1]
Print
Jump to:  



Login with username, password and session length

Powered by SMF 1.1.11 | SMF © 2006-2007, Simple Machines LLC
Copyright © 2006-2008 Futurescale, Inc.