/** * Convert a Comment array into a Comment object. * * @param array $aComment Comment. * * @return Comment converted object. */ private static function convertToObject($aComment) { $oComment = new Comment(); $oComment->setComment($aComment['comment']); $oComment->setMark(intval($aComment['mark'])); $oComment->setDate($aComment['date']); $oComment->setName($aComment['name']); $oUser = new User(); $oUser->setEmail($aComment['user_email']); $oComment->setUser(UserManager::get($oUser)); $oComment->setProduct(ProductManager::get($aComment['product_id'])); return $oComment; }
public static function getAll() { $aAll = array(); if (array_key_exists('cart', $_SESSION)) { foreach ($_SESSION['cart'] as $iProductId => $iQuantity) { $oProduct = ProductManager::get($iProductId); if ($oProduct) { // product should exists ! if (false === $oProduct) { continue; } // convert to CartProduct $oProduct = CartProduct::create($oProduct); $oProduct->setQuantity($iQuantity); $aAll[] = $oProduct; } } } return $aAll; }
private function archiveAction() { $iId = intval($_GET['id']); $oProduct = ProductManager::get($iId); if ($oProduct->getActive() == 1) { $result = ProductManager::archive($iId); } if ($oProduct->getActive() == 0) { $result = ProductManager::display($iId); } $aProducts = ProductManager::getAll(); require ROOT . 'src/ecommerce/view/product/list.php'; }
private function validateAction() { $iId = intval($_GET['id']); $email = $_GET['email']; $oProduct = ProductManager::get($iId); $oUser = UserManager::getFromEmail($email); $oComment = CommentManager::get($oProduct, $oUser); $oComment = CommentManager::validate($oProduct, $oUser); }