X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/airbundle/blobdiff_plain/42d2646c377a92fd92d37e09ef6b733fa9b50946..bda45c555c96461e7a0e9533360c2d79fa805438:/Repository/SnippetRepository.php diff --git a/Repository/SnippetRepository.php b/Repository/SnippetRepository.php index a1d696b..c070333 100644 --- a/Repository/SnippetRepository.php +++ b/Repository/SnippetRepository.php @@ -1,27 +1,35 @@ - + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ namespace Rapsys\AirBundle\Repository; -use Symfony\Component\Translation\TranslatorInterface; -use Doctrine\ORM\Query\ResultSetMapping; +use Rapsys\AirBundle\Repository; /** * SnippetRepository */ -class SnippetRepository extends \Doctrine\ORM\EntityRepository { +class SnippetRepository extends Repository { /** - * 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->manager + ->createQuery('SELECT s FROM Rapsys\AirBundle\Entity\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