code: public function attachShared(SharedEventManagerInterface $events)
      {
          $events->attach('*', NotificationEvent::EVENT_NOTIFICATION_ADD, array($this,'add'), 1);
          $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_DISPATCH, array($this,'renderJSON'), -240);
          $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_DISPATCH, array($this,'renderHTML'), -250);
          // Sometimes the Dispatch-Event is not reached, for instance with a route-direct
          // but also for Events, that are happening after the Dispatch
          $events->attach('Zend\Mvc\Application', MvcEvent::EVENT_FINISH, array($this,'renderHTML'), -250);
          return $this;
      }
docs: @param SharedEventManagerInterface $events
  
  @return $this