From: Raphaƫl Gertz Date: Mon, 19 Oct 2020 07:47:47 +0000 (+0200) Subject: Add findAllPseudonymBySession function X-Git-Tag: 0.1.3~10 X-Git-Url: https://git.rapsys.eu/airbundle/commitdiff_plain/6176927836d9b190c78d59e1a986b3e7ee79e065 Add findAllPseudonymBySession function --- diff --git a/Repository/UserRepository.php b/Repository/UserRepository.php index 0d0ee4e..8b490c4 100644 --- a/Repository/UserRepository.php +++ b/Repository/UserRepository.php @@ -100,4 +100,26 @@ class UserRepository extends \Doctrine\ORM\EntityRepository { //Send result return $ret; } + + /** + * Find all user's pseudonym from session applications + * + * @param $session The Session instance + */ + public function findAllPseudonymBySession($session) { + //Get entity manager + $em = $this->getEntityManager(); + + //Fetch sessions + $ret = $this->getEntityManager() + ->createQuery('SELECT u.id, u.pseudonym FROM RapsysAirBundle:Application a INNER JOIN RapsysAirBundle:User u WHERE u.id = a.user AND a.session = :session') + ->setParameter('session', $session) + ->getResult(); + + //Process result + $ret = array_column($ret, 'pseudonym', 'id'); + + //Send result + return $ret; + } }