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
64 //XXX: entity short syntax removed in doctrine/persistence 3.x: https://github.com/doctrine/orm/issues/8818
66 'Rapsys\AirBundle\Entity\UserDance' => $qs->getJoinTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\User')->getAssociationMapping('dances'), $manager->getClassMetadata('Rapsys\AirBundle\Entity\User'), $dp),
67 'Rapsys\AirBundle\Entity\UserGroup' => $qs->getJoinTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\User')->getAssociationMapping('groups'), $manager->getClassMetadata('Rapsys\AirBundle\Entity\User'), $dp),
68 'Rapsys\AirBundle\Entity\UserLocation' => $qs->getJoinTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\User')->getAssociationMapping('locations'), $manager->getClassMetadata('Rapsys\AirBundle\Entity\User'), $dp),
69 'Rapsys\AirBundle\Entity\UserSubscription' => $qs->getJoinTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\User')->getAssociationMapping('subscriptions'), $manager->getClassMetadata('Rapsys\AirBundle\Entity\User'), $dp),
70 'Rapsys\AirBundle\Entity\Application' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Application'), $dp),
71 'Rapsys\AirBundle\Entity\Civility' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Civility'), $dp),
72 'Rapsys\AirBundle\Entity\Country' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Country'), $dp),
73 'Rapsys\AirBundle\Entity\Dance' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Dance'), $dp),
74 'Rapsys\AirBundle\Entity\GoogleCalendar' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\GoogleCalendar'), $dp),
75 'Rapsys\AirBundle\Entity\GoogleToken' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\GoogleToken'), $dp),
76 'Rapsys\AirBundle\Entity\Group' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Group'), $dp),
77 'Rapsys\AirBundle\Entity\Location' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Location'), $dp),
78 'Rapsys\AirBundle\Entity\Session' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Session'), $dp),
79 'Rapsys\AirBundle\Entity\Slot' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Slot'), $dp),
80 'Rapsys\AirBundle\Entity\Snippet' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\Snippet'), $dp),
81 'Rapsys\AirBundle\Entity\User' => $qs->getTableName($manager->getClassMetadata('Rapsys\AirBundle\Entity\User'), $dp),
82 //Set accuweather max number of daily pages
84 //Set accuweather max number of hourly pages
87 ':guestdelay' => 2 * 24 * 3600,
89 ':regulardelay' => 3 * 24 * 3600,
91 ':seniordelay' => 4 * 24 * 3600,
94 //Set regular group id
98 //Set afternoon slot id
100 //Set evening slot id
104 //XXX: days since last session after which guest regain normal priority
106 //XXX: session count until considered at regular delay
108 //XXX: pn_ratio over which considered at regular delay
110 //XXX: tr_ratio diff over which considered at regular delay
113 //XXX: or $manager->getConnection()->quote($this->locale) ???
114 ':locale' => $dp->quoteStringLiteral($this->locale
),
115 //XXX: Set limit used to workaround mariadb subselect optimization
116 ':limit' => PHP_INT_MAX
,
121 //Set quoted table name keys
122 $this->tableKeys
= array_keys($tables);
124 //Set quoted table name values
125 $this->tableValues
= array_values($tables);