From 7a0be510744f8f8abec3b9eb6e4d389e86949602 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 4 Oct 2022 09:07:23 +0200 Subject: [PATCH 1/1] Rename function findByLocaleUserId to findByUserIdLocaleIndexByLocationId Php strict Cleanup --- Repository/SnippetRepository.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Repository/SnippetRepository.php b/Repository/SnippetRepository.php index a1d696b..2da863e 100644 --- a/Repository/SnippetRepository.php +++ b/Repository/SnippetRepository.php @@ -1,27 +1,33 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ -use Symfony\Component\Translation\TranslatorInterface; -use Doctrine\ORM\Query\ResultSetMapping; +namespace Rapsys\AirBundle\Repository; /** * SnippetRepository */ class SnippetRepository extends \Doctrine\ORM\EntityRepository { /** - * Find snippets by locale and user id + * Find snippets by user id, locale and index by location id * + * @param int $user The user * @param string $locale The locale - * @param User|int $user The user - * @return array The snippets or empty array + * @return array The snippets array */ - public function findByLocaleUserId($locale, $user) { + public function findByUserIdLocaleIndexByLocationId(int $userId, string $locale): array { //Fetch snippets - $ret = $this->getEntityManager() - ->createQuery('SELECT s FROM RapsysAirBundle:Snippet s WHERE s.locale = :locale and s.user = :user') + $ret = $this->_em + ->createQuery('SELECT s FROM RapsysAirBundle:Snippet s INDEX BY s.location WHERE s.locale = :locale and s.user = :user') + ->setParameter('user', $userId) ->setParameter('locale', $locale) - ->setParameter('user', $user) ->getResult(); //Send result -- 2.41.1