public function create(Application $app, Request $request)
 {
     if ($request->getMethod() == 'POST') {
         $menu = new Menu();
         $menu->setNom($request->get('nom'));
         $menu->setPrix($request->get('prix'));
         $menu->setRestaurant($request->get('restau'));
         $menu->setProduit($request->get('primary'));
         if ($request->get('boisson') == 'on') {
             $menu->setBoisson(true);
         } else {
             $menu->setBoisson(false);
         }
         if ($request->get('dessert') == 'on') {
             $menu->setDessert(true);
         } else {
             $menu->setDessert(false);
         }
         $app['repository.menus']->save($menu);
         return $app->redirect($app['url_generator']->generate('menu_index'));
     }
     $restaurants = $app['repository.restaurant']->findAll();
     $produits = $app['repository.produits']->findByType('primary');
     return $app['twig']->render('menu/create.html.twig', array('restaurants' => $restaurants, 'primarys' => $produits));
 }
 /**
  * Instantiates an menu entity and sets its properties using db data.
  *
  * @param array $menuData
  *   The array of db data.
  *
  * @return Menu
  */
 protected function buildMenu($menuData)
 {
     $menu = new Menu();
     $menu->setId($menuData['id']);
     $menu->setNom($menuData['nom']);
     $menu->setPrix($menuData['prix']);
     $restau = $this->app['repository.restaurant']->find($menuData['restaurant_id']);
     $menu->setRestaurant($restau);
     $primary = $this->app['repository.produits']->find($menuData['primary_id']);
     $menu->setProduit($primary);
     $menu->setBoisson($menuData['boisson']);
     $menu->setDessert($menuData['dessert']);
     return $menu;
 }