|
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\Orm\Entity\Alliance; |
|
10
|
|
|
use Stu\Orm\Entity\AllianceApplication; |
|
11
|
|
|
use Stu\Orm\Entity\User; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @extends EntityRepository<AllianceApplication> |
|
15
|
|
|
*/ |
|
16
|
|
|
final class AllianceApplicationRepository extends EntityRepository implements AllianceApplicationRepositoryInterface |
|
17
|
|
|
{ |
|
18
|
|
|
#[Override] |
|
19
|
|
|
public function prototype(): AllianceApplication |
|
20
|
|
|
{ |
|
21
|
|
|
return new AllianceApplication(); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
#[Override] |
|
25
|
|
|
public function save(AllianceApplication $application): void |
|
26
|
|
|
{ |
|
27
|
|
|
$em = $this->getEntityManager(); |
|
28
|
|
|
$em->persist($application); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
#[Override] |
|
32
|
|
|
public function delete(AllianceApplication $application): void |
|
33
|
|
|
{ |
|
34
|
|
|
$em = $this->getEntityManager(); |
|
35
|
|
|
$em->remove($application); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
1 |
|
#[Override] |
|
39
|
|
|
public function getByAlliance(int $allianceId): array |
|
40
|
|
|
{ |
|
41
|
1 |
|
return $this->createQueryBuilder('a') |
|
42
|
1 |
|
->where('a.alliance = :allianceId') |
|
43
|
1 |
|
->setParameter('allianceId', $allianceId) |
|
44
|
1 |
|
->orderBy('a.date', 'ASC') |
|
45
|
1 |
|
->getQuery() |
|
46
|
1 |
|
->getResult(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
#[Override] |
|
50
|
|
|
public function getByUser(int $userId): array |
|
51
|
|
|
{ |
|
52
|
|
|
return $this->createQueryBuilder('a') |
|
53
|
|
|
->where('a.user = :userId') |
|
54
|
|
|
->setParameter('userId', $userId) |
|
55
|
|
|
->getQuery() |
|
56
|
|
|
->getResult(); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
1 |
|
#[Override] |
|
60
|
|
|
public function getByUserAndAlliance(User $user, Alliance $alliance): ?AllianceApplication |
|
61
|
|
|
{ |
|
62
|
1 |
|
return $this->findOneBy([ |
|
63
|
1 |
|
'user' => $user, |
|
64
|
1 |
|
'alliance' => $alliance, |
|
65
|
1 |
|
]); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
#[Override] |
|
69
|
|
|
public function truncateByUser(int $userId): void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->getEntityManager()->createQuery( |
|
72
|
|
|
sprintf( |
|
73
|
|
|
'DELETE FROM %s a WHERE a.user = :userId', |
|
74
|
|
|
AllianceApplication::class |
|
75
|
|
|
) |
|
76
|
|
|
)->setParameters([ |
|
77
|
|
|
'userId' => $userId, |
|
78
|
|
|
])->execute(); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
#[Override] |
|
82
|
|
|
public function truncateByAlliance(int $allianceId): void |
|
83
|
|
|
{ |
|
84
|
|
|
$this->getEntityManager()->createQuery( |
|
85
|
|
|
sprintf( |
|
86
|
|
|
'DELETE FROM %s a WHERE a.alliance = :allianceId', |
|
87
|
|
|
AllianceApplication::class |
|
88
|
|
|
) |
|
89
|
|
|
)->setParameters([ |
|
90
|
|
|
'allianceId' => $allianceId, |
|
91
|
|
|
])->execute(); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
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