src/Controller/Kernel/UserController.php line 162

Open in your IDE?
  1. <?php /** @noinspection ALL */
  2. namespace App\Controller\Kernel;
  3. use App\Entity\Kernel\User;
  4. use App\Entity\Kernel\Organization;
  5. use App\Entity\Kernel\UserFunction;
  6. use App\Entity\Kernel\ListItem;
  7. use App\Entity\Kernel\Setting;
  8. use App\Entity\Kernel\ScreenConfigurationPage;
  9. use App\Entity\HR\Employee;
  10. use App\Form\Kernel\UserSimpleType;
  11. use App\Form\Kernel\UserProfileType;
  12. use App\Form\Kernel\UserProfileLimitedType;
  13. use App\Form\Kernel\UserAdminType;
  14. use App\Form\Kernel\UserPasswordType;
  15. use App\Repository\Kernel\UserRepository;
  16. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  17. use Symfony\Component\HttpFoundation\Request;
  18. use Symfony\Component\HttpFoundation\Response;
  19. use Symfony\Component\Routing\Annotation\Route;
  20. use App\Service\Kernel\UserService;
  21. use App\Service\Kernel\DMSService;
  22. /**
  23.  * @Route("/{_locale}/user")
  24.  */
  25. class UserController extends AbstractController
  26. {
  27.     /**
  28.      * @Route("/", name="user_index", methods={"GET"})
  29.      */
  30.     public function index(UserService $userService): Response
  31.     {
  32.         $classname explode("\\"get_class($this));
  33.         $arraysize count($classname);
  34.         $attribute str_replace("Controller"""$classname[$arraysize 1]).":".str_replace(
  35.                 "Action",
  36.                 "",
  37.                 __FUNCTION__
  38.             );
  39.         $this->denyAccessUnlessGranted($attribute);
  40.         $rights $userService->GetAuthorizationtype();
  41.         $em $this->getDoctrine()->getManager();
  42.         if ($this->getUser()->getOrganization() == null) {
  43.             $query $em->createQuery(
  44.                 "SELECT s FROM App\Entity\Kernel\User s LEFT JOIN s.userfunction t WHERE ((s.state = 0) AND ((s.userfunction is NULL) or (t.authorizationtype <= ?1)))"
  45.             );
  46.             $query $query->setParameter(1$rights);
  47.             $users $query->getResult();
  48.         } else {
  49.             $query $em->createQuery(
  50.                 "SELECT s FROM App\Entity\Kernel\User s LEFT JOIN s.userfunction t WHERE ((s.state = 0) AND ((s.organization = ?2) AND ((s.userfunction is NULL) or (t.authorizationtype <= ?1))))"
  51.             );
  52.             $query $query->setParameter(1$rights);
  53.             $query $query->setParameter(2$this->getUser()->getOrganization()->getId());
  54.             $users $query->getResult();
  55.         }
  56.         return $this->render('kernel/user/index.html.twig', [
  57.             'users' => $users,
  58.         ]);
  59.     }
  60.     
  61.     /**
  62.      * @Route("/showarchived", name="user_showarchived", methods={"GET"})
  63.      */
  64.     public function showarchived(UserService $userService): Response
  65.     {
  66.         $classname =  explode("\\"get_class($this));
  67.         $arraysize count($classname);
  68.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  69.         $this->denyAccessUnlessGranted($attribute);
  70.     
  71.         $rights $userService->GetAuthorizationtype();
  72.         $em $this->getDoctrine()->getManager();
  73.         if ($this->getUser()->getOrganization() == null)
  74.     {
  75.             $query $em->createQuery("SELECT s FROM App\Entity\Kernel\User s LEFT JOIN s.userfunction t WHERE ((s.state = 1) AND ((s.userfunction is NULL) or (t.authorizationtype <= ?1)))");
  76.         $query $query->setParameter(1$rights);
  77.             $users $query->getResult();
  78.     }
  79.     else
  80.     {
  81.             $query $em->createQuery("SELECT s FROM App\Entity\Kernel\User s LEFT JOIN s.userfunction t WHERE ((s.state = 1) AND ((s.organization = ?2) AND ((s.userfunction is NULL) or (t.authorizationtype <= ?1))))");
  82.             $query $query->setParameter(1$rights);
  83.         $query $query->setParameter(2$this->getUser()->getOrganization()->getId());
  84.             $users $query->getResult();
  85.     }
  86.         return $this->render('kernel/user/archived.html.twig', [
  87.             'users' => $users,
  88.         ]);
  89.     }
  90.     
  91.     /**
  92.      * @Route("/showdeleted", name="user_showdeleted", methods={"GET"})
  93.      */
  94.     public function showdeleted(UserService $userService): Response
  95.     {
  96.         $classname =  explode("\\"get_class($this));
  97.         $arraysize count($classname);
  98.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  99.         $this->denyAccessUnlessGranted($attribute);
  100.     
  101.         $rights $userService->GetAuthorizationtype();
  102.         $em $this->getDoctrine()->getManager();
  103.         if ($this->getUser()->getOrganization() == null)
  104.     {
  105.             $query $em->createQuery("SELECT s FROM App\Entity\Kernel\User s LEFT JOIN s.userfunction t WHERE ((s.state = 2) AND ((s.userfunction is NULL) or (t.authorizationtype <= ?1)))");
  106.         $query $query->setParameter(1$rights);
  107.             $users $query->getResult();
  108.     }
  109.     else
  110.     {
  111.             $query $em->createQuery("SELECT s FROM App\Entity\Kernel\User s LEFT JOIN s.userfunction t WHERE ((s.state = 2) AND ((s.organization = ?2) AND ((s.userfunction is NULL) or (t.authorizationtype <= ?1))))");
  112.             $query $query->setParameter(1$rights);
  113.         $query $query->setParameter(2$this->getUser()->getOrganization()->getId());
  114.             $users $query->getResult();
  115.     }
  116.         return $this->render('kernel/user/deleted.html.twig', [
  117.             'users' => $users,
  118.         ]);
  119.     }
  120.     
  121.     /**
  122.      * @Route("/home/{id}/{position?0}", name="user_home", methods={"GET"})
  123.      */
  124.     public function home(User $userint $positionUserService $userService): Response
  125.     {
  126.         $classname =  explode("\\"get_class($this));
  127.         $arraysize count($classname);
  128.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  129.         $this->denyAccessUnlessGranted($attribute$user);  
  130.         
  131.         $pages null;
  132.         
  133.         $currentuser $this->getUser();
  134.         
  135.         $continue true;
  136.         if ($currentuser->getId() != $user->getId())
  137.         {
  138.             $template $user->getUserFunction()->getUiTemplate();
  139.             if ($template != null)
  140.             {
  141.                 if ($template->getName() == "UITemplate.Default")
  142.                 {
  143.                     $continue true;
  144.                 }
  145.             }
  146.         }
  147.         
  148.         if ($continue == true)
  149.         {
  150.             $screenconfig $user->getUserFunction()->getSpecificScreenConfiguration();
  151.             $pages null;
  152.             if ($screenconfig != null)
  153.             {
  154.                 $entityManager $this->getDoctrine()->getManager();      
  155.                 $pages $entityManager->getRepository(ScreenConfigurationPage::class)->findBy(array('screenconfiguration' => $screenconfig'state' => 0), array('position' => 'ASC'));
  156.             }
  157.         }
  158.         return $this->render('kernel/user/home.html.twig', [
  159.             'user' => $user,
  160.             'position' => $position,
  161.             'pages' => $pages,
  162.         ]);
  163.     }
  164.     /**
  165.      * @Route("/new", name="user_new", methods={"GET","POST"})
  166.      */
  167.     public function new(Request $requestUserService $userService): Response
  168.     {
  169.         $classname =  explode("\\"get_class($this));
  170.         $arraysize count($classname);
  171.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  172.         $this->denyAccessUnlessGranted($attribute);
  173.     
  174.         $rights $userService->GetAuthorizationtype();
  175.         $organization $this->getUser()->getOrganization();
  176.         if ($organization != null)
  177.         {
  178.             $organization $organization->getId();
  179.         }
  180.         else
  181.         {
  182.             $organization = -1;
  183.         }
  184.         $user = new User();
  185.         if ($this->getUser()->getOrganization() == null)
  186.         {
  187.             $formFactory $this->get('form.factory');
  188.             $form $formFactory->createNamed('user',UserAdminType::class, $user
  189.                 ['rights' => $rights'organization' => $organization'action' => $this->generateUrl('user_new'), 'attr' => ['id' => $this->generateUrl('user_new')]]);
  190.         }
  191.         else
  192.         {
  193.             $formFactory $this->get('form.factory');
  194.             $form $formFactory->createNamed('user',UserSimpleType::class, $user
  195.                 ['rights' => $rights'organization' => $organization'action' => $this->generateUrl('user_new'), 'attr' => ['id' => $this->generateUrl('user_new')]]);
  196.         }
  197.         $form->handleRequest($request);
  198.         
  199.         $valid true;
  200.         $entityManager $this->getDoctrine()->getManager();
  201.         
  202.         if ($form->isSubmitted() == true)
  203.         {
  204.             $params $request->get('user'); //dubbel
  205.             
  206.             if (isset($params['userfunction']) == false)
  207.             {
  208.                 $this->get('session')->getFlashBag()->add('error''User.UserFunctionIsMandatory');
  209.                 $valid false;
  210.             }
  211.             else
  212.             {
  213.                 $userfunction $entityManager->getRepository(UserFunction::class)->findOneById($params['userfunction']);
  214.                 if ($this->getUser()->getOrganization() == null)
  215.                 {
  216.                     if (isset($params['organization']) == true)
  217.                     {
  218.                         if ($organization != -1)
  219.                         {
  220.                             $organization $entityManager->getRepository(Organization::class)->findOneById($params["organization"]);
  221.                             if ($organization != $userfunction->getOrganization())
  222.                             {
  223.                                 $this->get('session')->getFlashBag()->add('error''User.UserFunctionNotValidForOrganization');
  224.                                 $valid false;
  225.                             }
  226.                         }
  227.                     }
  228.                 }
  229.             }
  230.         }
  231.         if (($form->isSubmitted()) && ($valid == true)) {
  232.             
  233.             
  234.             
  235.             
  236.             
  237.             /*$entityManager = $this->getDoctrine()->getManager();
  238.             $user->setUuid($user->getEmail());
  239.             $user->setState(0);
  240.             $entityManager->persist($user);
  241.             $entityManager->flush();*/
  242.             $email $params['email'];
  243.             $firstName $params['firstName'];
  244.             $lastName $params['lastName'];
  245.             $timezone $params['timezone'];
  246.             $phone $params['phone'];
  247.             if (isset($params["enabled"]))
  248.             {
  249.                 $enabled true;
  250.             }
  251.             else
  252.             {
  253.                 $enabled false;
  254.             }
  255.             if (isset($params["locked"]))
  256.             {
  257.                 $locked true;
  258.             }
  259.             else
  260.             {
  261.                 $locked false;
  262.             }
  263.             if ($this->getUser()->getOrganization() == null)
  264.             {
  265.                 $organization $entityManager->getRepository(Organization::class)->findOneById($params["organization"]);
  266.             }
  267.             else
  268.             {
  269.                 $organization $this->getUser()->getOrganization(); 
  270.             }
  271.             $timezone $entityManager->getRepository(ListItem::class)->findOneById($params['timezone']);
  272.             $locale $entityManager->getRepository(ListItem::class)->findOneById($params['locale']);
  273.             $userfunction $entityManager->getRepository(UserFunction::class)->findOneById($params['userfunction']);
  274.             
  275.             $user $userService->CreateUser($email$email$firstName$lastNamenull$phone$locale$timezone$userfunction$organization0);
  276.                     
  277.             if (isset($params['employeeselect2']) == true) {
  278.                 $employeeselect2 $params['employeeselect2'];
  279.                 $employee null;
  280.                 $employeetype substr($employeeselect202);
  281.                 $employeeid substr($employeeselect22);
  282.                 if ($employeetype == "SU") {
  283.                     $user->setEmployee(
  284.                                $entityManager->getRepository(Employee::class)
  285.                                     ->findOneById($employeeid));
  286.                 }
  287.             }
  288.             $entityManager->persist($user);
  289.             $entityManager->flush();
  290.             
  291.             $this->denyAccessUnlessGranted($attribute$user);
  292.             return $this->redirectToRoute('user_index');
  293.         }
  294.         return $this->render('kernel/user/new.html.twig', [
  295.             'user' => $user,
  296.             'form' => $form->createView(),
  297.         ]);
  298.     }
  299.     
  300.     /**
  301.      * @Route("/profile", name="user_profile", methods={"GET"})
  302.      */
  303.     public function profile(): Response
  304.     {
  305.         $user $this->getUser();
  306.         
  307.         $classname =  explode("\\"get_class($this));
  308.         $arraysize count($classname);
  309.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  310.         $this->denyAccessUnlessGranted($attribute$user); 
  311.         
  312.         
  313.         return $this->render('kernel/user/profile.html.twig', [
  314.             'user' => $user,
  315.         ]);
  316.     }
  317.     /**
  318.      * @Route("/{id}", name="user_show", methods={"GET"})
  319.      */
  320.     public function show(User $user): Response
  321.     {
  322.         $classname =  explode("\\"get_class($this));
  323.         $arraysize count($classname);
  324.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  325.         $this->denyAccessUnlessGranted($attribute$user);  
  326.         
  327.         return $this->render('kernel/user/show.html.twig', [
  328.             'user' => $user,
  329.         ]);
  330.     }
  331.     
  332.     
  333.     
  334.     /**
  335.      * @Route("/{id}/audit", name="user_showaudit", methods={"GET"})
  336.      */
  337.     public function showaudit(User $user): Response
  338.     {
  339.         $classname =  explode("\\"get_class($this));
  340.         $arraysize count($classname);
  341.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  342.         $this->denyAccessUnlessGranted($attribute$user);  
  343.         
  344.         return $this->render('kernel/user/showaudit.html.twig', [
  345.             'user' => $user,
  346.         ]);
  347.     }
  348.     
  349.     /**
  350.      * @Route("/{id}/archive", name="user_archive", methods={"GET"})
  351.      */
  352.     public function archive(User $user): Response
  353.     {
  354.         $classname =  explode("\\"get_class($this));
  355.         $arraysize count($classname);
  356.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  357.         $this->denyAccessUnlessGranted($attribute$user); 
  358.         
  359.                 
  360.         $entityManager $this->getDoctrine()->getManager();
  361.         $user->setState(1);
  362.         $entityManager->persist($user);
  363.         $entityManager->flush();
  364.         
  365.         return $this->redirectToRoute('user_show', array('id' => $user->getId()));
  366.     }
  367.     
  368.     /**
  369.      * @Route("/{id}/restore", name="user_restore", methods={"GET"})
  370.      */
  371.     public function restore(User $user): Response
  372.     {
  373.         $classname =  explode("\\"get_class($this));
  374.         $arraysize count($classname);
  375.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  376.         $this->denyAccessUnlessGranted($attribute$user); 
  377.         
  378.                 
  379.         $entityManager $this->getDoctrine()->getManager();
  380.         $user->setState(0);
  381.         $entityManager->persist($user);
  382.         $entityManager->flush();
  383.         
  384.         return $this->redirectToRoute('user_show', array('id' => $user->getId()));
  385.     }
  386.     
  387.     /**
  388.      * @Route("/{id}/delete", name="user_logicaldelete", methods={"GET"})
  389.      */
  390.     public function logicaldelete(User $user): Response
  391.     {
  392.         $classname =  explode("\\"get_class($this));
  393.         $arraysize count($classname);
  394.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  395.         $this->denyAccessUnlessGranted($attribute$user); 
  396.         
  397.                 
  398.         $entityManager $this->getDoctrine()->getManager();
  399.         $user->setUuid($user->getUuid() . "_" date("Y-m-d H:i:s"));
  400.         $user->setState(2);
  401.         $entityManager->persist($user);
  402.         $entityManager->flush();
  403.         
  404.         //return $this->redirectToRoute('user_show', array('id' => $user->getId()));
  405.         return $this->redirectToRoute('user_index');
  406.     }
  407.     
  408.     /**
  409.      * @Route("/profile/edit", name="user_edit_profile", methods={"GET","POST"})
  410.      */
  411.     public function profileedit(Request $requestUserService $userServiceDMSService $dMSService): Response
  412.     {
  413.         $user $this->getUser();
  414.         
  415.         $classname =  explode("\\"get_class($this));
  416.         $arraysize count($classname);
  417.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  418.         $this->denyAccessUnlessGranted($attribute$user);
  419.         
  420.         $template $user->getUserFunction()->getUiTemplate();
  421.         $useruitemplate false;
  422.     if ($template != null)
  423.         {
  424.             if ($template->getName() == "UITemplate.User")
  425.             {
  426.         $useruitemplate true;
  427.             }
  428.         }
  429.         
  430.         $rights $userService->GetAuthorizationtype();
  431.         $organization $this->getUser()->getOrganization();
  432.         if ($organization != null)
  433.         {
  434.             $organization $organization->getId();
  435.         }
  436.         else
  437.         {
  438.             $organization = -1;
  439.         }
  440.         $template $this->getUser()->getUserFunction()->getUiTemplate();
  441.         $uiTemplate false;
  442.         if (($template != null) && ($template->getName() == 'UITemplate.User')) {
  443.             $form $this->createForm(UserProfileLimitedType::class, $user
  444.                     ['action' => $this->generateUrl('user_edit_profile'), 'attr' => ['id' => $this->generateUrl('user_edit_profile')]]);
  445.         
  446.         } else
  447.         {   
  448.             $form $this->createForm(UserProfileType::class, $user
  449.                     ['action' => $this->generateUrl('user_edit_profile'), 'attr' => ['id' => $this->generateUrl('user_edit_profile')]]);
  450.         }
  451.         $form->handleRequest($request);
  452.         if ($form->isSubmitted() && $form->isValid()) {
  453.             $this->getDoctrine()->getManager()->flush();
  454.             
  455.             $input $request->files->get('user_profile');
  456.             if($input != null)
  457.             {
  458.                 $uploadfile $input['picture'];
  459.                 if ($uploadfile != null)
  460.                 {
  461.                     $dMSService->addVersion($user->getPicture(), $uploadfile);
  462.                 }
  463.             }
  464.             if ($useruitemplate == true)
  465.             {
  466.                 return $this->redirectToRoute('user_home', array('id' => $user->getId()));
  467.             }
  468.             return $this->redirectToRoute('user_profile');
  469.         }
  470.         if ($useruitemplate == true)
  471.         {
  472.             return $this->render('kernel/user/editprofilesimple.html.twig', [
  473.                 'user' => $user,
  474.                 'form' => $form->createView(),
  475.                 'useruitemplate' => $useruitemplate
  476.             ]);
  477.         }
  478.         return $this->render('kernel/user/editprofile.html.twig', [
  479.             'user' => $user,
  480.             'form' => $form->createView(),
  481.             'useruitemplate' => $useruitemplate
  482.         ]);
  483.     }
  484.     /**
  485.      * @Route("/{id}/edit", name="user_edit", methods={"GET","POST"})
  486.      */
  487.     public function edit(Request $requestUser $userUserService $userServiceDMSService $dMSService): Response
  488.     {
  489.         $classname =  explode("\\"get_class($this));
  490.         $arraysize count($classname);
  491.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  492.         $this->denyAccessUnlessGranted($attribute$user); 
  493.         
  494.         $rights $userService->GetAuthorizationtype();
  495.         $organization $this->getUser()->getOrganization();
  496.         if ($organization != null)
  497.         {
  498.             $organization $organization->getId();
  499.         }
  500.         else
  501.         {
  502.             $organization = -1;
  503.         }
  504.         
  505.         $employees = array();
  506.         $employee "";
  507.         if ($user->getEmployee() != null)
  508.         {
  509.             $employees["".$user->getEmployee()] 
  510.                     = "SU".$user->getEmployee()->getId();
  511.             $employee "SU".$user->getEmployee()->getId();
  512.         }
  513.         
  514.         $form $this->createForm(UserSimpleType::class, $user
  515.                 ['employees' => $employees
  516.                  'employee' => $employee'rights' => $rights'organization' => $organization'action' => $this->generateUrl('user_edit', array('id' => $user->getId())), 'attr' => ['id' => $this->generateUrl('user_edit', array('id' => $user->getId()))]]);
  517.         $form->handleRequest($request);
  518.         if ($form->isSubmitted()) {
  519.             
  520.             $requestdata $request->get('user_simple'); //dubbel
  521.             if (isset($requestdata['employeeselect2']) == true) {
  522.                 $employeeselect2 $requestdata['employeeselect2'];
  523.                 $employee null;
  524.                 $employeetype substr($employeeselect202);
  525.                 $employeeid substr($employeeselect22);
  526.                 if ($employeetype == "SU") {
  527.                     $user->setEmployee(
  528.                                $this->getDoctrine()->getManager()->getRepository(Employee::class)
  529.                                     ->findOneById($employeeid));
  530.                 }
  531.                 if ($employeetype == "NO") {
  532.                     $user->setEmployee(null);
  533.                 }
  534.             }
  535.             
  536.             $this->getDoctrine()->getManager()->flush();
  537.             
  538.             $input $request->files->get('user');
  539.             if($input != null)
  540.             {
  541.                 $uploadfile $input['picture'];
  542.                 if ($uploadfile != null)
  543.                 {
  544.                     $dMSService->addVersion($user->getPicture(), $uploadfile);
  545.                 }
  546.             }
  547.             return $this->redirectToRoute('user_show', array('id' => $user->getId()));
  548.         }
  549.         return $this->render('kernel/user/edit.html.twig', [
  550.             'user' => $user,
  551.             'form' => $form->createView(),
  552.         ]);
  553.     }
  554.     
  555.     /**
  556.      * @Route("/profile/changepassword", name="user_changepassword_profile", methods={"GET","POST"})
  557.      */
  558.     public function profilechangepassword(Request $request,UserService $userService): Response
  559.     {
  560.         $user =  $this->getUser();
  561.         
  562.         $classname =  explode("\\"get_class($this));
  563.         $arraysize count($classname);
  564.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  565.         $this->denyAccessUnlessGranted($attribute$user); 
  566.         
  567.         $template $user->getUserFunction()->getUiTemplate();
  568.         $useruitemplate false;
  569.     if ($template != null)
  570.         {
  571.             if ($template->getName() == "UITemplate.User")
  572.             {
  573.         $useruitemplate true;
  574.             }
  575.         }
  576.         
  577.         
  578.         $form $this->createForm(UserPasswordType::class, $user
  579.                 ['action' => $this->generateUrl('user_changepassword_profile'), 'attr' => ['id' => $this->generateUrl('user_changepassword_profile')]]);
  580.         $form->handleRequest($request);
  581.         if ($form->isSubmitted() && $form->isValid()) {
  582.             
  583.             $userService->UpdatePassword($user$user->getPassword());
  584.             //$this->getDoctrine()->getManager()->flush();
  585.             if ($useruitemplate == true)
  586.             {
  587.                 return $this->redirectToRoute('user_home', array('id' => $user->getId()));
  588.             }
  589.             return $this->redirectToRoute('user_profile');
  590.         }
  591.         
  592.         if ($useruitemplate == true)
  593.         {
  594.             return $this->render('kernel/user/changepasswordprofilesimple.html.twig', [
  595.                 'user' => $user,
  596.                 'form' => $form->createView(),
  597.                 'useruitemplate' => $useruitemplate
  598.             ]);
  599.         }
  600.         return $this->render('kernel/user/changepasswordprofile.html.twig', [
  601.             'user' => $user,
  602.             'form' => $form->createView(),
  603.             'useruitemplate' => $useruitemplate
  604.         ]);
  605.     }
  606.     
  607.     /**
  608.      * @Route("/{id}/changepassword", name="user_changepassword", methods={"GET","POST"})
  609.      */
  610.     public function changepassword(Request $requestUser $userUserService $userService): Response
  611.     {
  612.         $classname =  explode("\\"get_class($this));
  613.         $arraysize count($classname);
  614.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  615.         $this->denyAccessUnlessGranted($attribute$user); 
  616.         
  617.         
  618.         $form $this->createForm(UserPasswordType::class, $user
  619.                 ['action' => $this->generateUrl('user_changepassword', array('id' => $user->getId())), 'attr' => ['id' => $this->generateUrl('user_changepassword', array('id' => $user->getId()))]]);
  620.         $form->handleRequest($request);
  621.         if ($form->isSubmitted() && $form->isValid()) {
  622.             
  623.             $userService->UpdatePassword($user$user->getPassword());
  624.             //$this->getDoctrine()->getManager()->flush();
  625.             return $this->redirectToRoute('user_show', array('id' => $user->getId()));
  626.         }
  627.         return $this->render('kernel/user/changepassword.html.twig', [
  628.             'user' => $user,
  629.             'form' => $form->createView(),
  630.         ]);
  631.     }
  632.     /**
  633.      * @Route("/{id}", name="user_delete", methods={"DELETE"})
  634.      */
  635.     public function delete(Request $requestUser $user): Response
  636.     {
  637.         $classname =  explode("\\"get_class($this));
  638.         $arraysize count($classname);
  639.         $attribute str_replace("Controller"""$classname[$arraysize-1]) . ":" str_replace("Action"""__FUNCTION__);
  640.         $this->denyAccessUnlessGranted($attribute$user); 
  641.     
  642.         if ($this->isCsrfTokenValid('delete'.$user->getId(), $request->request->get('_token'))) {
  643.             $entityManager $this->getDoctrine()->getManager();
  644.             $entityManager->remove($user);
  645.             $entityManager->flush();
  646.         }
  647.         return $this->redirectToRoute('user_index');
  648.     }
  649. }