plugin/announcement/Manager/AnnouncementManager.php
public function sendMessage(Announcement $announcement, array $users = [])
    {
        $message = $this->getMessage($announcement, $users);

        $announcementSend = new AnnouncementSend();
        $data = $message;
        $data['receivers'] = array_map(function (User $receiver) {
            return $receiver->getUsername();
        }, $message['receivers']);
        $data['sender'] = $message['sender']->getUsername();
        $announcementSend->setAnnouncement($announcement);
        $announcementSend->setData($data);
        $this->om->persist($announcementSend);
        $this->om->flush();

        $this->eventDispatcher->dispatch(
            'claroline_message_sending_to_users',
            'SendMessage',
            [
                $message['sender'],
                $message['content'],
                $message['object'],
                null,
                $message['receivers'],
            ]
        );
    }
public function sendMessage(Announcement $announcement, array $users = [])
    {
        $message = $this->getMessage($announcement, $users);

        $announcementSend = new AnnouncementSend();
        $data = $message;
        $data['receivers'] = array_map(function (User $receiver) {
            return $receiver->getUsername();
        }, $message['receivers']);
        $data['sender'] = $message['sender']->getUsername();
        $announcementSend->setAnnouncement($announcement);
        $announcementSend->setData($data);
        $this->om->persist($announcementSend);
        $this->om->flush();

        $this->eventDispatcher->dispatch(
            'claroline_message_sending_to_users',
            'SendMessage',
            [
                $message['sender'],
                $message['content'],
                $message['object'],
                null,
                $message['receivers'],
            ]
        );
    }
public function sendMessage ( Announcement $ announcement , array $ users = [ ] ) { $ message = $ this -> getMessage ( $ announcement , $ users ) ; $ announcementSend = new AnnouncementSend ( ) ; $ data = $ message ; $ data [ 'receivers' ] = array_map ( function ( User $ receiver ) { return $ receiver -> getUsername ( ) ; } , $ message [ 'receivers' ] ) ; $ data [ 'sender' ] = $ message [ 'sender' ] -> getUsername ( ) ; $ announcementSend -> setAnnouncement ( $ announcement ) ; $ announcementSend -> setData ( $ data ) ; $ this -> om -> persist ( $ announcementSend ) ; $ this -> om -> flush ( ) ; $ this -> eventDispatcher -> dispatch ( 'claroline_message_sending_to_users' , 'SendMessage' , [ $ message [ 'sender' ] , $ message [ 'content' ] , $ message [ 'object' ] , null , $ message [ 'receivers' ] , ] ) ; }
Sends an Announcement by message to Users that can access it.

@param Announcement $announcement
@param array        $users
Sends an Announcement by message to Users that can access it .