private function handleGetUserEvent(GetUserEvent $event, EventManagerInterface $eventManager)
 {
     $requestedUserId = $event->getRequest()->getRouteParameterCollection()->getParameterValue('id');
     $user = ['id' => $requestedUserId, 'email' => '*****@*****.**', 'forename' => 'Jonas', 'surname' => 'Rudolph'];
     $responseContent = ['user' => $user];
     $response = new Response($responseContent);
     $eventManager->dispatch(new ResponseEvent($response));
 }
Beispiel #2
0
 public function run()
 {
     $this->eventManager->addEventListener($this);
     try {
         //Save request for writing response in correct format
         $this->request = $this->requestReader->readRequest();
         $routeFoundEvent = $this->router->getEventForRequest($this->request);
         $this->eventManager->dispatch($routeFoundEvent);
     } catch (Exception $e) {
         $response = $this->exceptionHandler->turnExceptionIntoResponse($e);
         try {
             $this->eventManager->dispatch(new ResponseEvent($response));
         } catch (Exception $exceptionDuringExceptionHandling) {
             throw $exceptionDuringExceptionHandling;
         }
     } finally {
         exit;
     }
 }