*/
$app->get('/shop_cart/{id}', function ($id, Request $request) use($app) {
    $allCartsLine = $app['dao.shop_cart']->findAllByUser($id);
    $total = 0;
    foreach ($allCartsLine as $line) {
        $total += $line->getPkm()->getPrice() * $line->getQte();
    }
    return $app['twig']->render('shop_cart.html.twig', array('title' => 'Mon panier', 'cartsLine' => $allCartsLine, 'total' => $total));
})->bind('shop_cart');
/* Add the selected article in the user shop cart if there is no mistakes.
 * Then display the shop_cart view for the selected user.
 */
$app->match('/shop_cart/add/{iduser}/{idpkm}', function ($iduser, $idpkm, Request $request) use($app) {
    $pokemon = $app['dao.pokemons']->find($idpkm);
    $user = $app['dao.users']->find($iduser);
    $line = new Panier();
    $line->setUser($user);
    $line->setPkm($pokemon);
    $line->setQte(1);
    try {
        $app['dao.shop_cart']->save($line);
        /* Reduce the quantity available in the pokemon table */
        $pokemon->setStock($pokemon->getStock() - 1);
        $app['dao.pokemons']->update($pokemon);
    } catch (Exception $e) {
        $app['session']->getFlashBag()->add('problem', 'Problème lors l\'ajout dans le panier !');
        return $app->redirect($app['url_generator']->generate('shop_cart', array('id' => $iduser)));
    }
    return $app->redirect($app['url_generator']->generate('shop_cart', array('id' => $iduser)));
})->bind('add_shop_cart');
/* Remove the selected article in the user shop cart (just one).
 protected function buildDomainObject($row)
 {
     $panier = new Panier();
     if (array_key_exists('idpkm', $row)) {
         $idpkm = $row['idpkm'];
         $pkm = $this->pkmDAO->find($idpkm);
         $panier->setPkm($pkm);
     }
     if (array_key_exists('idUser', $row)) {
         $idUser = $row['idUser'];
         $user = $this->userDAO->find($idUser);
         $panier->setUser($user);
     }
     $panier->setQte($row['qte']);
     return $panier;
 }