Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Welcome, Guest. Please login or register.
August 17, 2017, 08:04:14 PM
Home Help Search Login Register
News: Please DM @puremvc on Twitter to gain forum access. Spambots are why we can't have nice things.
Pages: [1]
Print
Author Topic: notifyObservers edit suggested  (Read 3055 times)
saad
Sr. Member
****
Posts: 65


View Profile
« 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: