I have run the query that returns quite a bit of data. In my controller I do
public function viewAction()
{
$repository = $this
->getDoctrine()
->getManager()
->getRepository('NickAlertBundle:AvailabilityAlert');
$alerts = $repository->getAllActiveAlerts();
var_dump($alerts);
return $this->render('NickAlertBundle:Page:view.html.twig', array(
'alert' => $alerts,
));
}
That var_dump
contains the data I need, it looks like
array (size=2)
0 =>
array (size=4)
0 =>
object(Nick\AlertBundle\Entity\AvailabilityAlert)[320]
private 'id' => int 34
private 'searchCommand' => string 'LONMEL' (length=12)
private 'isConnecting' => string 'no' (length=2)
private 'lastUpdated' =>
object(DateTime)[323]
...
private 'isDeleted' => boolean false
private 'alertStatus' => string 'Active' (length=6)
'classes' => string 'Business' (length=3)
'flight_number' => string 'VS7' (length=3)
1 =>
....
How would I go about getting this data displaying in my Twig file? I have tried
{{ alert.getSearchCommand() }}
{{ alert.searchCommand }}
{{ alert }}
But most of the time I get the following error:
An exception has been thrown during the rendering of a template ("Notice: Array to string conversion")
So I was wondering how can I get this data displaying correctly?