/**
* 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);
});
}
}