Manager/Manager.php
public function sendMessageNotification(Message $message, User $user)
    {
        $forum = $message->getSubject()->getCategory()->getForum();
        $notifications = $this->notificationRepo->findBy(array('forum' => $forum));
        $users = array();

        foreach ($notifications as $notification) {
            $users[] = $notification->getUser();
        }

        $title = $this->translator->trans(
            'forum_new_message',
            array('%forum%' => $forum->getResourceNode()->getName(), '%subject%' => $message->getSubject()->getTitle(), '%author%' => $message->getCreator()->getUsername()),
            'forum'
        );

        $url = $this->router->generate(
            'claro_forum_subjects', array('category' => $message->getSubject()->getCategory()->getId()), true
        );

        $body = "<a href='{$url}'>{$title}</a><hr>{$message->getContent()}";

        $this->mailManager->send($title, $body, $users);
    }
public function sendMessageNotification(Message $message, User $user)
    {
        $forum = $message->getSubject()->getCategory()->getForum();
        $notifications = $this->notificationRepo->findBy(array('forum' => $forum));
        $users = array();

        foreach ($notifications as $notification) {
            $users[] = $notification->getUser();
        }

        $title = $this->translator->trans(
            'forum_new_message',
            array('%forum%' => $forum->getResourceNode()->getName(), '%subject%' => $message->getSubject()->getTitle(), '%author%' => $message->getCreator()->getUsername()),
            'forum'
        );

        $url = $this->router->generate(
            'claro_forum_subjects', array('category' => $message->getSubject()->getCategory()->getId()), true
        );

        $body = "<a href='{$url}'>{$title}</a><hr>{$message->getContent()}";

        $this->mailManager->send($title, $body, $users);
    }
public function sendMessageNotification ( Message $ message , User $ user ) { $ forum = $ message -> getSubject ( ) -> getCategory ( ) -> getForum ( ) ; $ notifications = $ this -> notificationRepo -> findBy ( array ( 'forum' => $ forum ) ) ; $ users = array ( ) ; foreach ( $ notifications as $ notification ) { $ users [ ] = $ notification -> getUser ( ) ; } $ title = $ this -> translator -> trans ( 'forum_new_message' , array ( '%forum%' => $ forum -> getResourceNode ( ) -> getName ( ) , '%subject%' => $ message -> getSubject ( ) -> getTitle ( ) , '%author%' => $ message -> getCreator ( ) -> getUsername ( ) ) , 'forum' ) ; $ url = $ this -> router -> generate ( 'claro_forum_subjects' , array ( 'category' => $ message -> getSubject ( ) -> getCategory ( ) -> getId ( ) ) , true ) ; $ body = "<a href='{$url}'>{$title}</a><hr>{$message->getContent()}" ; $ this -> mailManager -> send ( $ title , $ body , $ users ) ; }
Send a notification to a user about a message.

@param \Claroline\ForumBundle\Entity\Message $message
@param \Claroline\CoreBundle\Entity\User $user
Send a notification to a user about a message .