add validation of existing file

This commit is contained in:
2018-06-07 16:54:13 +02:00
parent 299491cb5b
commit fcc74c993d
11 changed files with 75 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Symfony\Component\Translation\TranslatorInterface;
/**
* @Route("/{_locale}/person/{person}/document")
@@ -21,6 +22,18 @@ use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
*/
class DocumentPersonController extends Controller
{
/**
*
* @var TranslatorInterface
*/
protected $translator;
public function __construct(TranslatorInterface $translator)
{
$this->translator = $translator;
}
/**
* @Route("/", name="person_document_index", methods="GET")
*/
@@ -84,8 +97,12 @@ class DocumentPersonController extends Controller
$em = $this->getDoctrine()->getManager();
$em->persist($document);
$em->flush();
$this->addFlash('success', $this->translator->trans("The document is successfully registered"));
return $this->redirectToRoute('person_document_index', ['person' => $person->getId()]);
} elseif ($form->isSubmitted() and !$form->isValid()) {
$this->addFlash('error', $this->translator->trans("This form contains errors"));
}
return $this->render('ChillDocStoreBundle:PersonDocument:new.html.twig', [
@@ -128,10 +145,14 @@ class DocumentPersonController extends Controller
if ($form->isSubmitted() && $form->isValid()) {
$this->getDoctrine()->getManager()->flush();
$this->addFlash('success', $this->translator->trans("The document is successfully updated"));
return $this->redirectToRoute(
'person_document_edit',
['id' => $document->getId(), 'person' => $person->getId()]);
} elseif ($form->isSubmitted() and !$form->isValid()) {
$this->addFlash('error', $this->translator->trans("This form contains errors"));
}
return $this->render(