Skip to content

Instantly share code, notes, and snippets.

@zetas
Created August 26, 2013 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zetas/6344495 to your computer and use it in GitHub Desktop.
Save zetas/6344495 to your computer and use it in GitHub Desktop.
I love symfony2
/**
* @Route("/", name="trade_index")
* @Route("/direct", name="trade_index_direct")
* @Route("/escrow", name="trade_index_escrow")
* @Template()
*/
public function indexAction($_route)
{
$sortArray = array(
'completedByUser' => null,
'active' => true
);
($_route == "trade_index_direct") ? $sortArray['type'] = 'direct' : null;
($_route == "trade_index_escrow") ? $sortArray['type'] = 'escrow' : null;
$trades = $this->getDoctrine()
->getRepository('MainTradeBundle:Trade')
->findBy($sortArray);
if (!$trades)
throw $this->createNotFoundException('No trades available');
return array('trades' => $trades, 'trade_route' => $_route);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment