public function trigger($eventName, Subject $data = null)
{
$eventName = $this->_config['eventPrefix'] . '.' . $eventName;
$Subject = $data ?: $this->getSubject();
$Subject->addEvent($eventName);
if (!empty($this->_config['eventLogging'])) {
$this->logEvent($eventName, $data);
}
$Event = new Event($eventName, $Subject);
$this->_eventManager->dispatch($Event);
if ($Event->result instanceof Response) {
$Exception = new Exception();
$Exception->response = $Event->result;
throw $Exception;
}
return $Event;
}