Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
ConformiteOrganisationSubscriber | |
100.00% |
7 / 7 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getSubscribedEvents | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
calculConformite | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace App\Domain\Registry\Symfony\EventSubscriber\Kernel; |
4 | |
5 | use App\Domain\Registry\Calculator\ConformiteOrganisationConformiteCalculator; |
6 | use App\Domain\Registry\Symfony\EventSubscriber\Event\ConformiteOrganisationEvent; |
7 | use Doctrine\ORM\EntityManagerInterface; |
8 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
9 | |
10 | class ConformiteOrganisationSubscriber implements EventSubscriberInterface |
11 | { |
12 | /** |
13 | * @var ConformiteOrganisationConformiteCalculator |
14 | */ |
15 | private $calculator; |
16 | |
17 | /** |
18 | * @var EntityManagerInterface |
19 | */ |
20 | private $entityManager; |
21 | |
22 | public function __construct(ConformiteOrganisationConformiteCalculator $calculator, EntityManagerInterface $entityManager) |
23 | { |
24 | $this->calculator = $calculator; |
25 | $this->entityManager = $entityManager; |
26 | } |
27 | |
28 | public static function getSubscribedEvents() |
29 | { |
30 | return [ |
31 | ConformiteOrganisationEvent::class => ['calculConformite'], |
32 | ]; |
33 | } |
34 | |
35 | public function calculConformite(ConformiteOrganisationEvent $event) |
36 | { |
37 | $this->calculator->calculEvaluationConformites($event->getEvaluation()); |
38 | |
39 | $this->entityManager->flush(); |
40 | } |
41 | } |