]> Raphaël G. Git Repositories - airbundle/blob - Repository/SnippetRepository.php
Remove body template
[airbundle] / Repository / SnippetRepository.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Repository;
13
14 /**
15 * SnippetRepository
16 */
17 class SnippetRepository extends \Doctrine\ORM\EntityRepository {
18 /**
19 * Find snippets by user id, locale and index by location id
20 *
21 * @param int $user The user
22 * @param string $locale The locale
23 * @return array The snippets array
24 */
25 public function findByUserIdLocaleIndexByLocationId(int $userId, string $locale): array {
26 //Fetch snippets
27 $ret = $this->_em
28 ->createQuery('SELECT s FROM RapsysAirBundle:Snippet s INDEX BY s.location WHERE s.locale = :locale and s.user = :user')
29 ->setParameter('user', $userId)
30 ->setParameter('locale', $locale)
31 ->getResult();
32
33 //Send result
34 return $ret;
35 }
36 }