<?php
 
require_once("classes/User.class.php");
require_once(
"classes/Cart.class.php");
require_once(
"classes/Wine.class.php");
require_once(
"classes/Product.class.php");

require_once(
"header.php");

    
// We use phpersistence to get the cart object.
    
$persistence = new Persistence();
    
$currentCart $persistence->getById("Cart"1);
    
/**
 * In this part of the script we instanciate products using their unique ids
 * and put them into the cart by populating the products array of Cart
 */  
    
    // persistence loads a wine with id 1
    
$wine $persistence->getById("Wine"1);
    
    
// We load a product and dont need to know if its a Wine or a shirt (usage of inheritance)
    
$product $persistence->getById("Product"3);
    
    
// We put the products in the cart
    
$currentCart->products[] = $wine;
    
$currentCart->products[] = $product;
    
    
// one line saves it all...
    
$persistence->saveOrUpdate($currentCart);
    
    
// done.
    
Logger::debug($currentCart);
    
    
?>