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
;
14 use Doctrine\ORM\EntityManagerInterface
;
15 use Doctrine\ORM\EntityRepository
;
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 Repository
extends EntityRepository
{
29 * The table keys array
33 protected array $tableKeys;
36 * The table values array
40 protected array $tableValues;
43 * Initializes a new LocationRepository instance
45 * @param EntityManagerInterface $manager The EntityManagerInterface instance
46 * @param ClassMetadata $class The ClassMetadata instance
47 * @param RouterInterface $router The router instance
48 * @param SluggerUtil $slugger The SluggerUtil instance
49 * @param TranslatorInterface $translator The TranslatorInterface instance
50 * @param string $locale The current locale
51 * @param array $languages The languages list
53 public function __construct(protected EntityManagerInterface
$manager, protected ClassMetadata
$class, protected RouterInterface
$router, protected SluggerUtil
$slugger, protected TranslatorInterface
$translator, protected string $locale, protected array $languages) {
54 //Call parent constructor
55 parent
::__construct($manager, $class);
58 $qs = $this->manager
->getConfiguration()->getQuoteStrategy();
59 $dp = $this->manager
->getConnection()->getDatabasePlatform();
61 //Set quoted table names
62 //XXX: this allow to make this code table name independent
63 //XXX: remember to place longer prefix before shorter to avoid strange replacings
65 'RapsysAirBundle:UserDance' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('dances'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
66 'RapsysAirBundle:UserGroup' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('groups'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
67 'RapsysAirBundle:UserLocation' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('locations'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
68 'RapsysAirBundle:UserSubscription' => $qs->getJoinTableName($manager->getClassMetadata('RapsysAirBundle:User')->getAssociationMapping('subscriptions'), $manager->getClassMetadata('RapsysAirBundle:User'), $dp),
69 'RapsysAirBundle:Application' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Application'), $dp),
70 'RapsysAirBundle:Civility' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Civility'), $dp),
71 'RapsysAirBundle:Country' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Country'), $dp),
72 'RapsysAirBundle:Dance' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Dance'), $dp),
73 'RapsysAirBundle:GoogleCalendar' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:GoogleCalendar'), $dp),
74 'RapsysAirBundle:GoogleToken' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:GoogleToken'), $dp),
75 'RapsysAirBundle:Group' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Group'), $dp),
76 'RapsysAirBundle:Location' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Location'), $dp),
77 'RapsysAirBundle:Session' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Session'), $dp),
78 'RapsysAirBundle:Slot' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Slot'), $dp),
79 'RapsysAirBundle:Snippet' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:Snippet'), $dp),
80 'RapsysAirBundle:User' => $qs->getTableName($manager->getClassMetadata('RapsysAirBundle:User'), $dp),
81 //Set accuweather max number of daily pages
83 //Set accuweather max number of hourly pages
86 ':guestdelay' => 2 * 24 * 3600,
88 ':regulardelay' => 3 * 24 * 3600,
90 ':seniordelay' => 4 * 24 * 3600,
93 //Set regular group id
97 //Set afternoon slot id
103 //XXX: days since last session after which guest regain normal priority
105 //XXX: session count until considered at regular delay
107 //XXX: pn_ratio over which considered at regular delay
109 //XXX: tr_ratio diff over which considered at regular delay
112 //XXX: or $manager->getConnection()->quote($this->locale) ???
113 ':locale' => $dp->quoteStringLiteral($this->locale
),
114 //XXX: Set limit used to workaround mariadb subselect optimization
115 ':limit' => PHP_INT_MAX
,
120 //Set quoted table name keys
121 $this->tableKeys
= array_keys($tables);
123 //Set quoted table name values
124 $this->tableValues
= array_values($tables);