Total Complexity | 7 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class ComponentSubscriber implements EntitySubscriberInterface |
||
13 | { |
||
14 | public function supportsEntity($entity = null): bool |
||
17 | } |
||
18 | |||
19 | public function getSubscribedEvents(): array |
||
20 | { |
||
21 | return [ |
||
22 | Events::preRemove |
||
23 | ]; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @param LifecycleEventArgs $eventArgs |
||
28 | * @param AbstractComponent $component |
||
29 | */ |
||
30 | public function preRemove(LifecycleEventArgs $eventArgs, AbstractComponent $component): void |
||
31 | { |
||
32 | $entityManager = $eventArgs->getEntityManager(); |
||
33 | if ($component->onDeleteCascade()) { |
||
34 | $this->deleteSubComponents($component, $entityManager); |
||
35 | } |
||
36 | } |
||
37 | /** |
||
38 | * @param AbstractComponent $component |
||
39 | * @param EntityManagerInterface $entityManager |
||
40 | */ |
||
41 | private function deleteSubComponents(AbstractComponent $component, EntityManagerInterface $entityManager): void |
||
50 | } |
||
51 | } |
||
52 | } |
||
54 |