separate things of user in forms

This commit is contained in:
Kayn Ty 2018-05-24 11:07:20 +02:00
parent 19144377fe
commit 3159adcdca
No known key found for this signature in database
GPG Key ID: 55B09AA0ED327CD3
4 changed files with 12 additions and 7 deletions

View File

@ -21,9 +21,8 @@ class FestivalController extends Controller {
* @Method("GET")
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$festivals = $em->getRepository( 'AppBundle:Festival' )->findByUser( $this->getUser() );
$festivals = $this->getUser()->getFestivals();
return $this->render( 'festival/index.html.twig',
[

View File

@ -21,7 +21,6 @@ class ProductCategoryController extends Controller {
* @Method("GET")
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$currentUser = $this->getUser();
$productCategories = $currentUser->getCategories();
@ -69,6 +68,9 @@ class ProductCategoryController extends Controller {
* @Method("GET")
*/
public function showAction( ProductCategory $productCategory ) {
if ( $productCategory->getUser()->getId() !== $this->getUser()->getId() ) {
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
}
$deleteForm = $this->createDeleteForm( $productCategory );
return $this->render( 'productcategory/show.html.twig',

View File

@ -21,9 +21,8 @@ class ProductController extends Controller {
* @Method("GET")
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$products = $em->getRepository( 'AppBundle:Product' )->findByUser( $this->getUser() );
$products = $this->getUser()->getProducts();
return $this->render( 'product/index.html.twig',
[
@ -65,6 +64,9 @@ class ProductController extends Controller {
* @Method("GET")
*/
public function showAction( Product $product ) {
if ( $product->getUser()->getId() !== $this->getUser()->getId() ) {
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
}
$deleteForm = $this->createDeleteForm( $product );
if ( $product->getUser()->getId() !== $this->getUser()->getId() ) {

View File

@ -21,9 +21,8 @@ class SellRecordController extends Controller {
* @Method("GET")
*/
public function indexAction() {
$em = $this->getDoctrine()->getManager();
$sellRecords = $em->getRepository( 'AppBundle:SellRecord' )->findByUser( $this->getUser() );
$sellRecords = $this->getUser()->getProductsSold();
return $this->render( 'sellrecord/index.html.twig',
[
@ -65,6 +64,9 @@ class SellRecordController extends Controller {
* @Method("GET")
*/
public function showAction( SellRecord $sellRecord ) {
if ( $sellRecord->getUser()->getId() !== $this->getUser()->getId() ) {
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );
}
$deleteForm = $this->createDeleteForm( $sellRecord );
if ( ! $sellRecord->getUser() == $this->getUser()->getId() ) {
$this->denyAccessUnlessGranted( 'ROLE_ADMIN' );