<?php
namespace App\Controller\Pack;
use App\Entity\PfoNotif;
use App\Repository\PfoNotifRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/pack/pfo/notif", name="pack_pfo_notif")
*/
class PfoNotifController extends AbstractController
{
/**
* @Route("/show/{id}", name="_show")
*/
public function show(PfoNotif $pfoNotif)
{
return new Response($pfoNotif->getNotif());
}
/**
* @Route("/in-progress", name="_in_progress")
*/
public function inProgress(PfoNotifRepository $prn):JsonResponse
{
$notif = $prn->findOneBy([
'percent' => 100,
'seen' => false
]);
if($notif == null){
return new JsonResponse([
'name' => 'none',
]);
}
$notif->setSeen(true);
$this->getDoctrine()->getManager()->flush();
$portfolio = $notif->getPortfolio();
if($portfolio != null){
return new JsonResponse([
'name' => $portfolio->getName(),
'url' => $this->generateUrl('pack_upload_progres', ['id' => $portfolio->getId()])
]);
}
return new JsonResponse([]);
}
}