示例#1
0
 /**
  * @param Request $request
  * @param Response $response
  * @param $args
  * @return Response
  */
 public function dispatch(Request $request, Response $response, $args)
 {
     $data = [];
     if ($request->isPost()) {
         $magnetUri = $request->getParam('magnetUri');
         if ($magnetUri) {
             $torrent = Torrent::fromMagnet($magnetUri);
             $data['torrent'] = $torrent;
             $data['torrentLink'] = (new Torcache())->getDownloadUrl($torrent);
         }
     }
     $this->view->render($response, 'home.twig', $data);
     return $response;
 }