PureMVC Architects Lounge

PureMVC Manifold => Standard Version => Topic started by: saad on May 07, 2012, 12:59:52



Title: notifyObservers edit suggested
Post by: saad on May 07, 2012, 12:59:52
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 );
  }
}