|
5 | 5 | use Hackzilla\Bundle\TicketBundle\Event\TicketEvent; |
6 | 6 | use Hackzilla\Bundle\TicketBundle\Form\Type\TicketMessageType; |
7 | 7 | use Hackzilla\Bundle\TicketBundle\Form\Type\TicketType; |
| 8 | +use Hackzilla\Bundle\TicketBundle\Model\TicketInterface; |
8 | 9 | use Hackzilla\Bundle\TicketBundle\Model\TicketMessageInterface; |
9 | 10 | use Hackzilla\Bundle\TicketBundle\TicketEvents; |
10 | 11 | use Hackzilla\Bundle\TicketBundle\TicketRole; |
@@ -75,7 +76,7 @@ public function createAction(Request $request) |
75 | 76 | ->setUser($this->getUserManager()->getCurrentUser()); |
76 | 77 |
|
77 | 78 | $ticketManager->updateTicket($ticket, $message); |
78 | | - $this->get('event_dispatcher')->dispatch(TicketEvents::TICKET_CREATE, new TicketEvent($ticket)); |
| 79 | + $this->dispatchTicketEvent(TicketEvents::TICKET_CREATE, $ticket); |
79 | 80 |
|
80 | 81 | return $this->redirect($this->generateUrl('hackzilla_ticket_show', ['ticketId' => $ticket->getId()])); |
81 | 82 | } |
@@ -174,8 +175,7 @@ public function replyAction(Request $request, $ticketId) |
174 | 175 | if ($form->isValid()) { |
175 | 176 | $message->setUser($user); |
176 | 177 | $ticketManager->updateTicket($ticket, $message); |
177 | | - |
178 | | - $this->get('event_dispatcher')->dispatch(TicketEvents::TICKET_UPDATE, new TicketEvent($ticket)); |
| 178 | + $this->dispatchTicketEvent(TicketEvents::TICKET_UPDATE, $ticket); |
179 | 179 |
|
180 | 180 | return $this->redirect($this->generateUrl('hackzilla_ticket_show', ['ticketId' => $ticket->getId()])); |
181 | 181 | } |
@@ -224,14 +224,19 @@ public function deleteAction(Request $request, $ticketId) |
224 | 224 | } |
225 | 225 |
|
226 | 226 | $ticketManager->deleteTicket($ticket); |
227 | | - $event = new TicketEvent($ticket); |
228 | | - $this->get('event_dispatcher')->dispatch(TicketEvents::TICKET_DELETE, $event); |
| 227 | + $this->dispatchTicketEvent(TicketEvents::TICKET_DELETE, $ticket); |
229 | 228 | } |
230 | 229 | } |
231 | 230 |
|
232 | 231 | return $this->redirect($this->generateUrl('hackzilla_ticket')); |
233 | 232 | } |
234 | 233 |
|
| 234 | + private function dispatchTicketEvent($ticketEvent, TicketInterface $ticket) |
| 235 | + { |
| 236 | + $event = new TicketEvent($ticket); |
| 237 | + $this->get('event_dispatcher')->dispatch($ticketEvent, $event); |
| 238 | + } |
| 239 | + |
235 | 240 | /** |
236 | 241 | * Creates a form to delete a Ticket entity by id. |
237 | 242 | * |
|
0 commit comments