Loading module/Application/src/Application/Controller/IndexController.php +1 −2 Changes for module/Application/src/Application/Controller/IndexController.php: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -33,8 +33,7 @@ class IndexController extends AbstractActionController $connectedUser = $this->getUserService()->getConnectedUser(); if ($this->getServiceUserContext()->getLdapUser()) { $supannId = ((int) $this->getServiceUserContext()->getLdapUser()->getSupannEmpId()); $agent = $this->getAgentService()->getAgentBySupannId($supannId); $agent = $this->getAgentService()->getAgentByUsername($connectedUser->getUsername()); if ($connectedUser !== null && $agent !== null && $agent->getUtilisateur() === null) { $agent->setUtilisateur($connectedUser); Loading module/Application/src/Application/Service/Agent/AgentService.php +20 Changes for module/Application/src/Application/Service/Agent/AgentService.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -204,6 +204,26 @@ EOS; return $result; } /** * @param string|null $unsername * @return Agent|null */ public function getAgentByUsername(?string $username) : ?Agent { if ($username === null) return null; $qb = $this->getEntityManager()->getRepository(Agent::class)->createQueryBuilder('agent') ->andWhere('agent.login = :username') ->setParameter('username', $username) ; try { $result = $qb->getQuery()->getOneOrNullResult(); } catch (NonUniqueResultException $e) { throw new RuntimeException("Plusieurs Agent liés au même Username [".$username."]", $e); } return $result; } /** * @param int $supannId * @return Agent|null Loading Loading
module/Application/src/Application/Controller/IndexController.php +1 −2 Changes for module/Application/src/Application/Controller/IndexController.php: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -33,8 +33,7 @@ class IndexController extends AbstractActionController $connectedUser = $this->getUserService()->getConnectedUser(); if ($this->getServiceUserContext()->getLdapUser()) { $supannId = ((int) $this->getServiceUserContext()->getLdapUser()->getSupannEmpId()); $agent = $this->getAgentService()->getAgentBySupannId($supannId); $agent = $this->getAgentService()->getAgentByUsername($connectedUser->getUsername()); if ($connectedUser !== null && $agent !== null && $agent->getUtilisateur() === null) { $agent->setUtilisateur($connectedUser); Loading
module/Application/src/Application/Service/Agent/AgentService.php +20 Changes for module/Application/src/Application/Service/Agent/AgentService.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -204,6 +204,26 @@ EOS; return $result; } /** * @param string|null $unsername * @return Agent|null */ public function getAgentByUsername(?string $username) : ?Agent { if ($username === null) return null; $qb = $this->getEntityManager()->getRepository(Agent::class)->createQueryBuilder('agent') ->andWhere('agent.login = :username') ->setParameter('username', $username) ; try { $result = $qb->getQuery()->getOneOrNullResult(); } catch (NonUniqueResultException $e) { throw new RuntimeException("Plusieurs Agent liés au même Username [".$username."]", $e); } return $result; } /** * @param int $supannId * @return Agent|null Loading