From 9fee83e207852d30cd1b88b156c760cb944ab786 Mon Sep 17 00:00:00 2001 From: Wilmer Ramones Date: Fri, 7 Oct 2016 09:05:56 -0400 Subject: [PATCH] CORRECCION DE ERROR: corregido error donde no le asignaba el rol ROLE_DOCENTE al profesor de la unidad curricular --- src/AppBundle/Controller/SeccionController.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/AppBundle/Controller/SeccionController.php b/src/AppBundle/Controller/SeccionController.php index 1c17f13..39c6cc7 100644 --- a/src/AppBundle/Controller/SeccionController.php +++ b/src/AppBundle/Controller/SeccionController.php @@ -47,11 +47,14 @@ class SeccionController extends Controller if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); - - $user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion()); - if (false === $this->get('security.authorization_checker')->isGranted('ROLE_DOCENTE')) { - $user->addRol($this->getDoctrine()->getRepository('AppBundle:Role')->findOneByName("ROLE_DOCENTE")); - } + $nuevo_docente = $form->get('idRolInstitucion')->getData(); + $user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($nuevo_docente->getId()); + if( $user instanceof \Symfony\Component\Security\Core\User\UserInterface ){ + $roles = $user->getRoles(); + if ( ! in_array( 'ROLE_DOCENTE' , $roles ) ){ + $user->addRol($this->getDoctrine()->getRepository('AppBundle:Role')->findOneByName("ROLE_DOCENTE")); + } + } $em->persist($user); $em->persist($seccion); -- 2.0.0