]> Raphaël G. Git Repositories - airbundle/blob - Repository.php
Update execute member function prototype
[airbundle] / Repository.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;
13
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;
19
20 use Rapsys\PackBundle\Util\SluggerUtil;
21
22 /**
23 * Repository
24 *
25 * {@inheritdoc}
26 */
27 class Repository extends EntityRepository {
28 /**
29 * The table keys array
30 *
31 * @var array
32 */
33 protected array $tableKeys;
34
35 /**
36 * The table values array
37 *
38 * @var array
39 */
40 protected array $tableValues;
41
42 /**
43 * Initializes a new LocationRepository instance
44 *
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
52 */
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);
56
57 //Get quote strategy
58 $qs = $this->manager->getConfiguration()->getQuoteStrategy();
59 $dp = $this->manager->getConnection()->getDatabasePlatform();
60
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 $tables = [
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
82 ':accudaily' => 12,
83 //Set accuweather max number of hourly pages
84 ':accuhourly' => 3,
85 //Set guest delay
86 ':guestdelay' => 2 * 24 * 3600,
87 //Set regular delay
88 ':regulardelay' => 3 * 24 * 3600,
89 //Set senior delay
90 ':seniordelay' => 4 * 24 * 3600,
91 //Set guest group id
92 ':guestid' => 2,
93 //Set regular group id
94 ':regularid' => 3,
95 //Set senior group id
96 ':seniorid' => 4,
97 //Set afternoon slot id
98 ':afternoonid' => 2,
99 //Set evening slot id
100 ':eveningid' => 3,
101 //Set after slot id
102 ':afterid' => 4,
103 //XXX: days since last session after which guest regain normal priority
104 ':guestwait' => 30,
105 //XXX: session count until considered at regular delay
106 ':scount' => 5,
107 //XXX: pn_ratio over which considered at regular delay
108 ':pnratio' => 1,
109 //XXX: tr_ratio diff over which considered at regular delay
110 ':trdiff' => 5,
111 //Set locale
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,
116 "\t" => '',
117 "\n" => ' '
118 ];
119
120 //Set quoted table name keys
121 $this->tableKeys = array_keys($tables);
122
123 //Set quoted table name values
124 $this->tableValues = array_values($tables);
125 }
126 }