コード例 #1
0
ファイル: admin.php プロジェクト: Kanizada/MicroStore
use MicroStore\Domain\Produit;
use MicroStore\Domain\User;
use MicroStore\Domain\Commande;
use MicroStore\DAO\UserDAO;
use MicroStore\DAO\ProduitDAO;
use MicroStore\DAO\CommandeDAO;
$admin = $app['controllers_factory'];
$admin->get('/backoffice', function () use($app) {
    $produitDAO = new ProduitDAO($app['db']);
    $mesProduits = $produitDAO->findAll();
    $quantiteProduits = 0;
    foreach ($mesProduits as $key => $value) {
        $quantiteProduits += 1;
    }
    $userDAO = new UserDAO($app['db']);
    $mesUsers = $userDAO->findAll();
    $quantiteUsers = 0;
    foreach ($mesUsers as $key => $value) {
        $quantiteUsers += 1;
    }
    $quantiteCommandes = 0;
    $commandeDAO = new CommandeDAO($app['db']);
    $mesCommandes = $commandeDAO->findAll();
    $quantiteCommandes = 0;
    foreach ($mesCommandes as $key => $value) {
        $quantiteCommandes += 1;
    }
    return $app['twig']->render('admin/backoffice.html.twig', array('tableauProduits' => $mesProduits, 'quantiteProduits' => $quantiteProduits, 'tableauUsers' => $mesUsers, 'quantiteUsers' => $quantiteUsers, 'quantiteCommandes' => $quantiteCommandes));
})->bind('backoffice');
$admin->get('/gestionUtilisateurs', function () use($app) {
    $userDAO = new UserDAO($app['db']);