-
Notifications
You must be signed in to change notification settings - Fork 0
/
repositories.php
102 lines (82 loc) · 4.16 KB
/
repositories.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
declare(strict_types=1);
use DI\ContainerBuilder;
use Doctrine\ORM\EntityManagerInterface;
use MatchBot\Application\Matching;
use MatchBot\Client;
use MatchBot\Domain\Campaign;
use MatchBot\Domain\CampaignFunding;
use MatchBot\Domain\CampaignFundingRepository;
use MatchBot\Domain\CampaignRepository;
use MatchBot\Domain\Charity;
use MatchBot\Domain\CharityRepository;
use MatchBot\Domain\DoctrineDonationRepository;
use MatchBot\Domain\Donation;
use MatchBot\Domain\DonationRepository;
use MatchBot\Domain\DonorAccount;
use MatchBot\Domain\DonorAccountRepository;
use MatchBot\Domain\Fund;
use MatchBot\Domain\FundingWithdrawal;
use MatchBot\Domain\FundingWithdrawalRepository;
use MatchBot\Domain\FundRepository;
use MatchBot\Domain\RegularGivingMandate;
use MatchBot\Domain\RegularGivingMandateRepository;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Lock\LockFactory;
return static function (ContainerBuilder $containerBuilder) {
$containerBuilder->addDefinitions([
CampaignFundingRepository::class => static function (ContainerInterface $c): CampaignFundingRepository {
$repository = $c->get(EntityManagerInterface::class)->getRepository(CampaignFunding::class);
\assert($repository instanceof CampaignFundingRepository);
return $repository;
},
CampaignRepository::class => static function (ContainerInterface $c): CampaignRepository {
$repo = $c->get(EntityManagerInterface::class)->getRepository(Campaign::class);
\assert($repo instanceof CampaignRepository);
$repo->setClient($c->get(Client\Campaign::class));
$repo->setLogger($c->get(LoggerInterface::class));
return $repo;
},
CharityRepository::class => static function (ContainerInterface $c): CharityRepository {
$repository = $c->get(EntityManagerInterface::class)->getRepository(Charity::class);
\assert($repository instanceof CharityRepository);
return $repository;
},
DonationRepository::class => static function (ContainerInterface $c): DonationRepository {
$repo = $c->get(EntityManagerInterface::class)->getRepository(Donation::class);
\assert($repo instanceof DoctrineDonationRepository);
$repo->setCampaignRepository($c->get(CampaignRepository::class));
$repo->setClient($c->get(Client\Donation::class));
$repo->setFundRepository($c->get(FundRepository::class));
$repo->setLogger($c->get(LoggerInterface::class));
$repo->setMatchingAdapter($c->get(Matching\Adapter::class));
return $repo;
},
FundRepository::class => static function (ContainerInterface $c): FundRepository {
$repo = $c->get(EntityManagerInterface::class)->getRepository(Fund::class);
assert($repo instanceof FundRepository);
$repo->setClient($c->get(Client\Fund::class));
$repo->setCampaignFundingRepository($c->get(CampaignFundingRepository::class));
$repo->setLogger($c->get(LoggerInterface::class));
$repo->setMatchingAdapter($c->get(Matching\Adapter::class));
return $repo;
},
FundingWithdrawalRepository::class => static function (ContainerInterface $c): FundingWithdrawalRepository {
$repository = $c->get(EntityManagerInterface::class)->getRepository(FundingWithdrawal::class);
\assert($repository instanceof FundingWithdrawalRepository);
return $repository;
},
DonorAccountRepository::class => static function (ContainerInterface $c): DonorAccountRepository {
$em = $c->get(EntityManagerInterface::class);
\assert($em instanceof EntityManagerInterface);
$repo = $em->getRepository(DonorAccount::class);
\assert($repo instanceof DonorAccountRepository);
return $repo;
},
RegularGivingMandateRepository::class =>
static fn(ContainerInterface $c): RegularGivingMandateRepository => new RegularGivingMandateRepository(
$c->get(EntityManagerInterface::class)
),
]);
};