2

I have an entity called Ticket.

In one of my controllers, I have an array or Tickets, that I would like to send to an other controller.

My first controller :

//some code...

return $this->redirect($this->generateUrl('tracker_ticket_view', array(
            'TicketId' => $ticket->getId(),   
            'lticket'  => $lticket   //$lticket contains an array of tickets
        )));

My other controller :

@Route("/view/{TicketId}/{lticket}", 
 * defaults = { "lticket" = null},
 * name="tracker_ticket_view")
 * @ParamConverter("ticket", class="AtgpTrackerBundle:Ticket", options={"id" = "TicketId"})
 * @Template()
 */
public function viewAction(Ticket $ticket, Request $request, Array $lticket)
{    

//some code... 

This code obviously gives me an Array to String exception. I guess lticket has to appear in the route, but symfony doesnt know what to type.

As I did here, we can send unique objects through controllers thanks to the Param Converter, but I dont know how to proceed with an array of object.

1 Answer 1

2

Instead of define a /view/{TicketId}/{lticket} route, pass the array to the query string.

/**
 * @Route("/view/{TicketId}", defaults = { "lticket" = null}, name="tracker_ticket_view")
 * @ParamConverter("ticket", class="AtgpTrackerBundle:Ticket", options={"id" = "TicketId"})
 * @Template()
 */
public function viewAction(Ticket $ticket, Request $request)
{
    $lticket = $request->query->get('lticket');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.