/**
  * @Route("/suggest-file", name="help_suggestfile")
  * @Method({"POST"})
  * @Template("ChaosTangentFansubEbooksAppBundle:Help:suggest-file.html.twig")
  */
 public function suggestFile(Request $request)
 {
     $form = $this->createForm(new SuggestFileType());
     $form->handleRequest($request);
     if ($form->isValid()) {
         $suggestion = new Suggestion();
         $suggestion->setIp($request->getClientIp())->setType('script');
         // fail early
         $authChecker = $this->get('security.authorization_checker');
         if ($authChecker->isGranted('suggest', $suggestion) === false) {
             // todo clean up upload
             throw new AccessDeniedHttpException('Unable to make series suggestion from that IP address again');
         }
         // todo try/catch
         $suggestFile = $form->getData();
         // set the originally uploaded name
         $suggestFile->uploadedFilename = $suggestFile->file->getClientOriginalName();
         // generate a unique filename
         $filename = (new \DateTime())->format('U') . '-' . hash_file('md5', $suggestFile->file->getPathname());
         $dir = $this->container->getParameter('script_temp_storage');
         // move it and replace the existing file
         $suggestFile->file = $suggestFile->file->move($dir, $filename);
         // update suggestion object
         $suggestion->setData($suggestFile);
         $om = $this->get('doctrine')->getManager();
         $om->persist($suggestion);
         $om->flush();
         return [];
     }
     return ['form' => $form->createView()];
 }
 /**
  * Get printable message for this activity
  *
  * @return string
  */
 public function getMessage()
 {
     if ($this->type == self::ACTIVITY_SERIES_ADD) {
         return 'New series "' . $this->object->getTitle() . '" added';
     } else {
         if ($this->type == self::ACTIVITY_VOTE_UP) {
             return 'Line #' . $this->object->getLine()->getId() . ' voted up';
         } else {
             if ($this->type == self::ACTIVITY_VOTE_DOWN) {
                 return 'Line #' . $this->object->getLine()->getId() . ' voted down';
             } else {
                 if ($this->type == self::ACTIVITY_SUGGEST_SERIES) {
                     return 'New series suggested';
                 } else {
                     if ($this->type == self::ACTIVITY_SUGGEST_SCRIPT) {
                         return 'New script submitted';
                     } else {
                         if ($this->type == self::ACTIVITY_FLAG) {
                             return 'Line #' . $this->object->getLine()->getId() . ' flagged as bad';
                         }
                     }
                 }
             }
         }
     }
     return 'Well, something happened';
 }