private function processUsers(\Club\MessageBundle\Entity\Message $message, $users) { foreach ($users as $user) { if ($message->getType() == 'mail') { $this->addRecipient($message, $user); } } }
/** * @Route("/message/add/{id}") * @Template() */ public function messageAddAction(\Club\MessageBundle\Entity\Message $message) { $em = $this->getDoctrine()->getManager(); $filter = $em->getRepository('ClubUserBundle:Filter')->findActive($this->getUser()); $users = $em->getRepository('ClubUserBundle:User')->getUsersListWithPagination($filter); foreach ($users as $u) { $message->addUser($u); } $em->persist($message); $em->flush(); $this->get('session')->getFlashBag()->add('notice', $this->get('translator')->trans('Your changes are saved.')); return $this->redirect($this->generateUrl('club_message_adminmessage_edit', array('id' => $message->getId()))); }
/** * @Route("/recipients/{id}") * @Template() */ public function recipientsAction(\Club\MessageBundle\Entity\Message $message) { return array('message' => $message, 'recipients' => $message->getMessageRecipients()); }