<?php
namespace App\Controller\Backend;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Doctrine\ORM\EntityManagerInterface;
class CertifiedPatientRecordController extends Controller
{
private $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
$this->entityManager = $entityManager;
}
public function authorizeAction(string $id)
{
$object = $this->admin->getSubject();
if (!$object) {
throw new NotFoundHttpException(sprintf('unable to find the object with id: %s', $id));
}
if ($object->isAllChecked()) {
$object->setAuthorized(true);
$this->entityManager->persist($object);
$this->entityManager->flush();
}
return new RedirectResponse($this->admin->generateUrl('list'));
}
}