addObserver() public méthode

This method registers a {@link http://www.php.net/manual/en/language.pseudo-types.php#language.types.callback callback} which is called when the notification corresponding to the criteria given at registration time is posted. The criteria are the notification name and eventually the class of the object posted with the notification. If there are any pending notifications corresponding to the criteria given here, the callback will be called straight away. If the notification name is empty, the observer will receive all the posted notifications. Same goes for the class name.
public addObserver ( $callback, $nName = EVENT_DISPATCHER_GLOBAL, $class = null ) : void
Résultat void
 /**
  * For the given plugin, add all the observers of this plugin.
  */
 private function addPluginObservers(Piwik_Plugin $plugin)
 {
     $hooks = $plugin->getListHooksRegistered();
     foreach ($hooks as $hookName => $methodToCall) {
         $this->dispatcher->addObserver(array($plugin, $methodToCall), $hookName);
     }
 }
 /**
  * For the given module, add all the observers of this module.
  */
 private function addModuleObservers(Core_Module $module)
 {
     $hooks = $module->getListHooksRegistered();
     foreach ($hooks as $hookName => $methodToCall) {
         $this->dispatcher->addObserver(array($module, $methodToCall), $hookName);
     }
 }