Total Complexity | 2 |
Total Lines | 27 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
13 | class ImageAddedSubscriber extends ImageSubscriber implements EventSubscriberInterface |
||
14 | { |
||
15 | /** |
||
16 | * Send Image to the database and set a flash message |
||
17 | * @param ImageEvent $event |
||
18 | */ |
||
19 | public function registerImageToDatabase(ImageEvent $event) |
||
20 | { |
||
21 | /**@var Image $image*/ |
||
22 | $image = $event->getEntity(); |
||
23 | // $this->sendToDatabase($event); |
||
24 | /** @var Trick $trick */ |
||
25 | $trick = $event->getTrick(); |
||
26 | $trick->addImage($image); |
||
27 | $this->em->persist($trick); |
||
28 | $this->em->flush(); |
||
29 | |||
30 | $this->addFlash(FlashMessageCategory::SUCCESS, 'Image Added'); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @return array The event names to listen to |
||
35 | */ |
||
36 | public static function getSubscribedEvents() |
||
40 | ]; |
||
41 | } |
||
42 | } |