| Total Complexity | 2 |
| Total Lines | 25 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class ImageDeletedSubscriber extends ImageSubscriber implements EventSubscriberInterface |
||
| 11 | { |
||
| 12 | |||
| 13 | public function deleteImageFromDatabase(ImageDeleteEvent $event) |
||
| 14 | { |
||
| 15 | $image = $event->getEntity(); |
||
| 16 | |||
| 17 | $trick = $event->getTrick(); |
||
| 18 | |||
| 19 | $trick->removeImage($image); |
||
| 20 | $this->em->persist($trick); |
||
| 21 | $this->em->flush(); |
||
| 22 | |||
| 23 | |||
| 24 | $this->addFlash(FlashMessageCategory::SUCCESS, 'image ' . $image->getTitle() . ' deleted'); |
||
| 25 | |||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return array The event names to listen to |
||
| 30 | */ |
||
| 31 | public static function getSubscribedEvents() |
||
| 35 | ]; |
||
| 36 | } |
||
| 39 | } |