Commit 9fee83e207852d30cd1b88b156c760cb944ab786

Authored by Wilmer Ramones
1 parent a334fa1e72
Exists in master

CORRECCION DE ERROR: corregido error donde no le asignaba el rol ROLE_DOCENTE al…

… profesor de la unidad curricular
src/AppBundle/Controller/SeccionController.php
... ... @@ -47,11 +47,14 @@ class SeccionController extends Controller
47 47  
48 48 if ($form->isSubmitted() && $form->isValid()) {
49 49 $em = $this->getDoctrine()->getManager();
50   -
51   - $user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($this->getUser()->getIdRolInstitucion());
52   - if (false === $this->get('security.authorization_checker')->isGranted('ROLE_DOCENTE')) {
53   - $user->addRol($this->getDoctrine()->getRepository('AppBundle:Role')->findOneByName("ROLE_DOCENTE"));
54   - }
  50 + $nuevo_docente = $form->get('idRolInstitucion')->getData();
  51 + $user = $this->getDoctrine()->getRepository('AppBundle:Usuarios')->findOneByIdRolInstitucion($nuevo_docente->getId());
  52 + if( $user instanceof \Symfony\Component\Security\Core\User\UserInterface ){
  53 + $roles = $user->getRoles();
  54 + if ( ! in_array( 'ROLE_DOCENTE' , $roles ) ){
  55 + $user->addRol($this->getDoctrine()->getRepository('AppBundle:Role')->findOneByName("ROLE_DOCENTE"));
  56 + }
  57 + }
55 58  
56 59 $em->persist($user);
57 60 $em->persist($seccion);
... ...