/**
  * @param Request $request
  *
  * @return Response
  */
 public function __invoke(Request $request)
 {
     $event = new HookResponseEvent();
     $event->team = $request->request->get('team_id');
     $event->channelId = $request->request->get('channel_id');
     $event->channelName = $request->request->get('channel_name');
     $event->timestamp = $request->request->get('timestamp');
     $event->userId = $request->request->get('user_id');
     $event->userName = $request->request->get('user_name');
     $event->text = $request->request->get('text');
     $event->triggerWord = $request->request->get('trigger_word');
     $event->slashCommand = $request->request->get('command');
     $event->response = new Response();
     $token = $request->request->get('token');
     $this->logger->debug('Received message from Slack.', ['token' => $token, 'event' => $event]);
     // Get slash command and/or trigger word
     // Make sure to check token from Slack
     if ($event->slashCommand && !in_array($token, $this->slashTokens) || !$event->slashCommand && !in_array($token, $this->outgoingTokens)) {
         $this->logger->error('Received invalid token from a request.', ['token' => $token, 'event' => $event]);
         throw new AccessDeniedException();
     }
     $this->dispatcher->dispatchResponse($event);
     return $event->response;
 }
 public function testEmptyDescriptor()
 {
     $dispatcher = new SlackDispatcher(new Logger());
     $dispatcher->register($this->getMockDescriptor(null, null, null, false));
     $event = new HookResponseEvent();
     $dispatcher->dispatchResponse($event);
 }