]> Raphaël G. Git Repositories - airbundle/blob - Repository/SnippetRepository.php
Replace _em now private with manager member variable
[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 use Rapsys\AirBundle\Repository;
15
16 /**
17 * SnippetRepository
18 */
19 class SnippetRepository extends Repository {
20 /**
21 * Find snippets by user id, locale and index by location id
22 *
23 * @param int $user The user
24 * @param string $locale The locale
25 * @return array The snippets array
26 */
27 public function findByUserIdLocaleIndexByLocationId(int $userId, string $locale): array {
28 //Fetch snippets
29 $ret = $this->manager
30 ->createQuery('SELECT s FROM Rapsys\AirBundle\Entity\Snippet s INDEX BY s.location WHERE s.locale = :locale and s.user = :user')
31 ->setParameter('user', $userId)
32 ->setParameter('locale', $locale)
33 ->getResult();
34
35 //Send result
36 return $ret;
37 }
38 }