1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Repository
;
14 use Doctrine\ORM\EntityManagerInterface
;
15 use Doctrine\ORM\EntityRepository
as BaseEntityRepository
;
16 use Doctrine\ORM\Mapping\ClassMetadata
;
17 use Symfony\Component\Routing\RouterInterface
;
18 use Symfony\Contracts\Translation\TranslatorInterface
;
20 use Rapsys\PackBundle\Util\SluggerUtil
;
27 class EntityRepository
extends BaseEntityRepository
{
29 * The RouterInterface instance
31 * @var RouterInterface
33 protected RouterInterface
$router;
36 * The SluggerUtil instance
40 protected SluggerUtil
$slugger;
43 * The table keys array
47 protected array $tableKeys;
50 * The table values array
54 protected array $tableValues;
57 * The TranslatorInterface instance
59 * @var TranslatorInterface
61 protected TranslatorInterface
$translator;
64 * The list of languages
68 protected array $languages = [];
71 * Initializes a new LocationRepository instance
73 * @param EntityManagerInterface $manager The EntityManagerInterface instance
74 * @param ClassMetadata $class The ClassMetadata instance
75 * @param RouterInterface $router The router instance
76 * @param SluggerUtil $slugger The SluggerUtil instance
77 * @param TranslatorInterface $translator The TranslatorInterface instance
78 * @param array $languages The languages list
80 public function __construct(EntityManagerInterface
$manager, ClassMetadata
$class, RouterInterface
$router, SluggerUtil
$slugger, TranslatorInterface
$translator, array $languages) {
81 //Call parent constructor
82 parent
::__construct($manager, $class);
85 $this->languages
= $languages;
88 $this->router
= $router;
91 $this->slugger
= $slugger;
94 $this->translator
= $translator;
97 $qs = $manager->getConfiguration()->getQuoteStrategy();
98 $dp = $manager->getConnection()->getDatabasePlatform();
100 //Set quoted table names
101 //XXX: this allow to make this code table name independent
102 //XXX: remember to place longer prefix before shorter to avoid strange replacings
104 'RapsysAirBundle:UserDance' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('dances'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
105 'RapsysAirBundle:UserGroup' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
106 'RapsysAirBundle:UserLocation' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('locations'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
107 'RapsysAirBundle:Application' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Application'), $dp),
108 'RapsysAirBundle:Civility' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Civility'), $dp),
109 'RapsysAirBundle:Country' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Country'), $dp),
110 'RapsysAirBundle:Dance' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Dance'), $dp),
111 'RapsysAirBundle:Group' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Group'), $dp),
112 'RapsysAirBundle:Location' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Location'), $dp),
113 'RapsysAirBundle:Session' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Session'), $dp),
114 'RapsysAirBundle:Slot' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Slot'), $dp),
115 'RapsysAirBundle:Snippet' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Snippet'), $dp),
116 'RapsysAirBundle:User' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:User'), $dp),
117 //Set accuweather max number of daily pages
119 //Set accuweather max number of hourly pages
122 ':guestdelay' => 2 * 24 * 3600,
124 ':regulardelay' => 3 * 24 * 3600,
126 ':seniordelay' => 4 * 24 * 3600,
129 //Set regular group id
131 //Set senior group id
133 //Set afternoon slot id
135 //Set evening slot id
139 //XXX: days since last session after which guest regain normal priority
141 //XXX: session count until considered at regular delay
143 //XXX: pn_ratio over which considered at regular delay
145 //XXX: tr_ratio diff over which considered at regular delay
147 //XXX: Set limit used to workaround mariadb subselect optimization
148 ':limit' => PHP_INT_MAX
,
153 //Set quoted table name keys
154 $this->tableKeys
= array_keys($tables);
156 //Set quoted table name values
157 $this->tableValues
= array_values($tables);