1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Orm\Repository; |
6
|
|
|
|
7
|
|
|
use Doctrine\ORM\EntityRepository; |
8
|
|
|
use Override; |
|
|
|
|
9
|
|
|
use Stu\Component\Database\DatabaseEntryTypeEnum; |
|
|
|
|
10
|
|
|
use Stu\Component\Ship\ShipRumpEnum; |
|
|
|
|
11
|
|
|
use Stu\Orm\Entity\DatabaseEntry; |
12
|
|
|
use Stu\Orm\Entity\Ship; |
13
|
|
|
use Stu\Orm\Entity\ShipRump; |
14
|
|
|
use Stu\Orm\Entity\ShipRumpBuildingFunction; |
15
|
|
|
use Stu\Orm\Entity\ShipRumpInterface; |
16
|
|
|
use Stu\Orm\Entity\ShipRumpUser; |
17
|
|
|
use Stu\Orm\Entity\Storage; |
18
|
|
|
use Stu\Orm\Entity\UserInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @extends EntityRepository<ShipRump> |
22
|
|
|
*/ |
23
|
|
|
final class ShipRumpRepository extends EntityRepository implements ShipRumpRepositoryInterface |
24
|
|
|
{ |
25
|
|
|
#[Override] |
26
|
|
|
public function save(ShipRumpInterface $post): void |
27
|
|
|
{ |
28
|
|
|
$em = $this->getEntityManager(); |
29
|
|
|
|
30
|
|
|
$em->persist($post); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
#[Override] |
34
|
|
|
public function getGroupedInfoByUser(UserInterface $user): array |
35
|
|
|
{ |
36
|
|
|
return $this->getEntityManager() |
37
|
|
|
->createQuery( |
38
|
|
|
sprintf( |
39
|
|
|
'SELECT s.rumps_id as rump_id, r.name, COUNT(s.id) as amount FROM %s s LEFT JOIN %s r WITH |
40
|
|
|
r.id = s.rumps_id WHERE s.user = :user GROUP BY s.rumps_id, r.name ORDER BY MIN(r.sort) ASC', |
41
|
|
|
Ship::class, |
42
|
|
|
ShipRump::class |
43
|
|
|
) |
44
|
|
|
) |
45
|
|
|
->setParameters([ |
46
|
|
|
'user' => $user |
47
|
|
|
]) |
48
|
|
|
->getResult(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
#[Override] |
52
|
|
|
public function getBuildableByUserAndBuildingFunction(int $userId, int $buildingFunction): array |
53
|
|
|
{ |
54
|
|
|
return $this->getEntityManager() |
55
|
|
|
->createQuery( |
56
|
|
|
sprintf( |
57
|
|
|
'SELECT r FROM %s r INDEX BY r.id WHERE r.is_buildable = :state AND r.id IN ( |
58
|
|
|
SELECT ru.rump_id FROM %s ru WHERE ru.user_id = :userId |
59
|
|
|
) AND r.id IN ( |
60
|
|
|
SELECT rubu.rump_id FROM %s rubu WHERE rubu.building_function = :buildingFunction |
61
|
|
|
)', |
62
|
|
|
ShipRump::class, |
63
|
|
|
ShipRumpUser::class, |
64
|
|
|
ShipRumpBuildingFunction::class |
65
|
|
|
) |
66
|
|
|
) |
67
|
|
|
->setParameters([ |
68
|
|
|
'state' => 1, |
69
|
|
|
'userId' => $userId, |
70
|
|
|
'buildingFunction' => $buildingFunction |
71
|
|
|
]) |
72
|
|
|
->getResult(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
#[Override] |
76
|
|
|
public function getBuildableByUser(int $userId): array |
77
|
|
|
{ |
78
|
|
|
return $this->getEntityManager() |
79
|
|
|
->createQuery( |
80
|
|
|
sprintf( |
81
|
|
|
'SELECT r FROM %s r INDEX BY r.id WHERE r.is_buildable = :state AND r.id IN ( |
82
|
|
|
SELECT ru.rump_id FROM %s ru WHERE ru.user_id = :userId |
83
|
|
|
)', |
84
|
|
|
ShipRump::class, |
85
|
|
|
ShipRumpUser::class |
86
|
|
|
) |
87
|
|
|
) |
88
|
|
|
->setParameters([ |
89
|
|
|
'state' => 1, |
90
|
|
|
'userId' => $userId, |
91
|
|
|
]) |
92
|
|
|
->getResult(); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
#[Override] |
96
|
|
|
public function getWithoutDatabaseEntry(): array |
97
|
|
|
{ |
98
|
|
|
return $this->getEntityManager() |
99
|
|
|
->createQuery( |
100
|
|
|
sprintf( |
101
|
|
|
'SELECT r FROM %s r WHERE r.database_id NOT IN (SELECT d.id FROM %s d WHERE d.type = :categoryId)', |
102
|
|
|
ShipRump::class, |
103
|
|
|
DatabaseEntry::class |
104
|
|
|
) |
105
|
|
|
) |
106
|
|
|
->setParameters([ |
107
|
|
|
'categoryId' => DatabaseEntryTypeEnum::DATABASE_TYPE_RUMP |
108
|
|
|
]) |
109
|
|
|
->getResult(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
#[Override] |
113
|
|
|
public function getStartableByColony(int $colonyId): array |
114
|
|
|
{ |
115
|
|
|
return $this->getEntityManager() |
116
|
|
|
->createQuery( |
117
|
|
|
sprintf( |
118
|
|
|
'SELECT r FROM %s r INDEX BY r.id |
119
|
|
|
WHERE r.is_buildable = :state |
120
|
|
|
AND r.category_id != :ignoreCategory AND r.commodity_id IN ( |
121
|
|
|
SELECT st.commodity_id FROM %s st WHERE st.colony_id = :colonyId |
122
|
|
|
)', |
123
|
|
|
ShipRump::class, |
124
|
|
|
Storage::class |
125
|
|
|
) |
126
|
|
|
) |
127
|
|
|
->setParameters([ |
128
|
|
|
'state' => 1, |
129
|
|
|
'ignoreCategory' => ShipRumpEnum::SHIP_CATEGORY_SHUTTLE, |
130
|
|
|
'colonyId' => $colonyId |
131
|
|
|
]) |
132
|
|
|
->getResult(); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
#[Override] |
136
|
|
|
public function getList(): iterable |
137
|
|
|
{ |
138
|
|
|
return $this->findBy( |
139
|
|
|
[], |
140
|
|
|
['id' => 'desc'] |
141
|
|
|
); |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths