Ejemplo n.º 1
0
 /**
  * Displays a form to create a new Message entity.
  *
  * @Route("/message/new/{userRecipient}-{auction}", name="message_new")
  * @Route("/message/new/{userRecipient}-{auction}/{subject}", name="message_new_subject")
  * @Method("GET")
  * @Template()
  */
 public function newAction($userRecipient, $auction, $subject = null)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $entity = new Message();
     $entity->setSubject($subject);
     $entity->setUserSender($user);
     $em = $this->getDoctrine()->getManager();
     $userRecipient = $em->getRepository('ApplicationSonataUserBundle:User')->findOneBy(array('username' => $userRecipient));
     $auction = $em->getRepository('AppBundle:Auction')->findOneBy(array('id' => $auction));
     $entity->setUserRecipient($userRecipient);
     $entity->setAuction($auction);
     $auction->addMessage($entity);
     $form = $this->createCreateForm($entity);
     return array('entity' => $entity, 'form' => $form->createView());
 }
Ejemplo n.º 2
0
 /**
  * Add message
  *
  * @param \AppBundle\Entity\Message $message
  *
  * @return Auction
  */
 public function addMessage(\AppBundle\Entity\Message $message)
 {
     $this->message[] = $message;
     $message->setAuction($this);
     return $this;
 }