improve CRUD and switch to symfony3

This commit is contained in:
2018-06-05 14:53:30 +02:00
parent a1ee85b0c0
commit eda8f2c033
11 changed files with 167 additions and 78 deletions

View File

@@ -11,6 +11,8 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
/**
* @Route("/{_locale}/person/{person}/document")
@@ -30,11 +32,11 @@ class DocumentPersonController extends Controller
throw $this->createNotFoundException('Person not found');
}
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$reachableScopes = $this->get('chill.main.security.authorization.helper')
->getReachableScopes(
$this->getUser(), new Role('CHILL_PERSON_DOCUMENT_SEE'),
$this->getUser(), new Role(PersonDocumentVoter::SEE),
$person->getCenter());
$documents = $em
@@ -61,11 +63,10 @@ class DocumentPersonController extends Controller
throw $this->createNotFoundException('person not found');
}
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
$user = $this->get('security.context')->getToken()->getUser();
$document = new PersonDocument();
$document->setUser($user);
$document->setUser($this->getUser());
$document->setPerson($person);
$document->setDate(new \DateTime('Now'));
@@ -115,8 +116,7 @@ class DocumentPersonController extends Controller
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
$this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_UPDATE', $document);
$user = $this->get('security.context')->getToken()->getUser();
$document->setUser($user);
$document->setUser($this->getUser());
$document->setDate(new \DateTime('Now'));
$form = $this->createForm(