Total Complexity | 5 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
10 | abstract class AppSubscriber |
||
11 | { |
||
12 | use AddFlashTrait; |
||
13 | |||
14 | /** |
||
15 | * @var EntityManagerInterface |
||
16 | */ |
||
17 | protected $em; |
||
18 | |||
19 | /** |
||
20 | * @return array The event names to listen to |
||
21 | */ |
||
22 | abstract public static function getSubscribedEvents(); |
||
23 | |||
24 | /** |
||
25 | * @param AppEvent $event |
||
26 | * Registers the trick into the database |
||
27 | */ |
||
28 | public function sendToDatabase(AppEvent $event) |
||
33 | } |
||
34 | |||
35 | public function deleteFromDatabase(AppEvent $event) |
||
36 | { |
||
37 | $entity = $event->getEntity(); |
||
38 | $this->em->remove($entity); |
||
39 | $this->em->flush(); |
||
40 | } |
||
41 | |||
42 | public function persist(AppEvent $event) |
||
43 | { |
||
44 | $entity = $event->getEntity(); |
||
45 | $this->em->persist($entity); |
||
46 | } |
||
47 | |||
48 | public function flush() |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @required |
||
55 | * @param EntityManagerInterface $em |
||
56 | */ |
||
57 | public function setEm(EntityManagerInterface $em): void |
||
60 | } |
||
61 | } |