public convert ( |
||
$request |
public function convert(Request $request)
{
try {
$parameters = $request->request->all();
if (array_key_exists('command', $parameters)) {
return new SlashCommand($parameters);
} elseif (empty($parameters)) {
$parameters = $request->query->all();
}
return new WebHook($parameters);
} catch (\Exception $exception) {
throw new UnexpectedValueException('Request could not be converted.', 0, $exception);
}
}
/** * Mediates Request handling between HttpKernelInterface and the Mainframe. * {@inheritdoc} */ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true) { $command = $this->converter->convert($request); $packet = $this->mainframe->execute($command); $content = $packet['output']; if ($command instanceof SlashCommand && $content instanceof Reply) { $content = $content->get('text'); } return new Response($content); }