src/Controller/Pack/PfoNotifController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Pack;
  3. use App\Entity\PfoNotif;
  4. use App\Repository\PfoNotifRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\JsonResponse;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. /**
  10.  * @Route("/pack/pfo/notif", name="pack_pfo_notif")
  11.  */
  12. class PfoNotifController extends AbstractController
  13. {
  14.     /**
  15.      * @Route("/show/{id}", name="_show")
  16.      */
  17.     public function show(PfoNotif $pfoNotif)
  18.     {
  19.        return new Response($pfoNotif->getNotif());
  20.     }
  21.     /**
  22.      * @Route("/in-progress", name="_in_progress")
  23.      */
  24.     public function inProgress(PfoNotifRepository $prn):JsonResponse
  25.     {
  26.         $notif $prn->findOneBy([
  27.             'percent' => 100,
  28.             'seen' => false
  29.         ]);
  30.         if($notif == null){
  31.             return new JsonResponse([
  32.                 'name' => 'none',
  33.             ]);
  34.         }
  35.         $notif->setSeen(true);
  36.         $this->getDoctrine()->getManager()->flush();
  37.         $portfolio $notif->getPortfolio();
  38.         if($portfolio != null){
  39.             return new JsonResponse([
  40.                 'name' => $portfolio->getName(),
  41.                 'url' => $this->generateUrl('pack_upload_progres', ['id' => $portfolio->getId()])
  42.             ]);
  43.         }
  44.         return new JsonResponse([]);
  45.     }
  46. }