addEvent() public method

Render template from event params
public addEvent ( string $content, integer $templateId, integer $userId ) : array
$content string Content
$templateId integer Template id
$userId integer User id
return array
Example #1
0
 /**
  * Boostrap
  *
  * @param Event $e Event
  *
  * @return void
  */
 public function onBootstrap(Event $e)
 {
     $this->template = new Template();
     $templates = $this->template->getTemplates();
     $application = $e->getApplication();
     $serviceManager = $application->getServiceManager();
     foreach ($templates as $template) {
         $this->events()->attach($template['event_identifier'], $template['event_name'], function (Event $event) use($template, $serviceManager) {
             $userId = null;
             $auth = $serviceManager->get('Auth');
             if ($auth->hasIdentity()) {
                 $userId = $auth->getIdentity()->getId();
                 $event->setParam('user', $auth->getIdentity()->getName());
             } else {
                 $remote = new RemoteAddress();
                 $event->setParam('user', $remote->getIpAddress());
             }
             $content = $this->template->render($event, $template);
             $this->template->addEvent($content, $template['id'], $userId);
         });
     }
 }