99
{
$comment= new Comment();
$form = $this->createForm(new
TicketCommentFormType(), $comment);
$form->handleRequest($this->request);
if ($form->isSubmitted() && $form->isValid()) {
$comment->setTicket($ticket);
$comment->setAuthor($this->user);
if (is_null($ticket->getUser()) && $this->user
!= $ticket->getAuthor()) {
$ticket->setUser($this->user);
$this->manager->persist($ticket);
}
$comment->upload();
$this->manager->persist($comment);
$this->manager->flush();
return $this-
>redirectToRoute('site_tickets_edit',
array('ticket'=>$ticket->getId()));
}
$this->forms['comment'] = $form->createView();
$this->view['ticket'] = $ticket;
$this->navigation = array('active' => 'tickets');
return $this-
>render('AppBundle:Tickets:edit.html.twig');
}
/**
* @param Ticket $ticket
* @param TicketStatus $status
* @return RedirectResponse|Response
* @Config\Route("/tickets/{ticket}/change/{status}",
name = "site_tickets_change")
* @Config\ParamConverter("ticket", options =
{"mapping": {"ticket": "id"}})
* @Config\ParamConverter("status", options =
{"mapping": {"srarus": "id"}})
*/
public function changeAction(Ticket $ticket,
TicketStatus $status)
{
$ticket->setStatus($status);
if ($status->getId()==4) {
$this->addNotice('success',
'tickets.html.twig',
array('notice' => 'closed', 'id' =>
$ticket->getId())
);