public function listen(ApplicationEvent $event) {
    if ($event->getStage() == ApplicationEvent::BEFORE_ROUTE_ACTION) {
      $request = $event->getRequest();
      if ($request != null) {
        $this->transformRequest($request);
      }
    }
    else if ($event->getStage() == ApplicationEvent::AFTER_EXECUTE_CONTROLLER) {
      $request = $event->getRequest();
      $response = $event->getResponse();
      if ($request != null && $response != null) {
        $this->transformResponse($request, $response);
      }
    }
  }