/** * @DI\Observe("delete_user") * * @param CreateFormResourceEvent $event */ public function onUserDelete(DeleteUserEvent $event) { $user = $event->getUser(); $chatUser = $this->chatManager->getChatUserByUser($user); if ($chatUser) { $this->chatManager->deleteChatUser($chatUser); } }
public function onDeleteUser(DeleteUserEvent $event) { //remove notification for user if it exists $em = $this->container->get('doctrine.orm.entity_manager'); $notificationRepo = $em->getRepository('ClarolineForumBundle:Notification'); $notifications = $notificationRepo->findOneBy(array('user' => $event->getUser())); if (count($notifications) > 0) { foreach ($notifications as $notification) { $em->remove($notification); } $em->flush(); } }