Refactored function

This commit is contained in:
Kevin Frantz
2018-07-14 22:11:21 +02:00
parent 0ace91c6a7
commit 560c70de38
2 changed files with 33 additions and 17 deletions

View File

@@ -4,7 +4,11 @@ namespace repository\product;
use Doctrine\Common\Collections\ArrayCollection;
use repository\AbstractRepository;
use entity\product\ProductInterface as ProductEntityInterface;
use entity\product\Product as ProductEntity;
use core\Core;
use entity\currency\Euro;
use entity\price\Price;
use entity\image\UrlImage;
/**
*
@@ -41,7 +45,29 @@ final class Product extends AbstractRepository implements ProductInterface
}
public function getAllProducts(): ArrayCollection
{}
{
$statement = $this->database->prepare('SELECT * FROM '.self::TABLE.';');
$statement->execute();
foreach ($statement->fetchAll() as $product){
}
}
static public function createProduct(string $name, string $color, int $cents, int $tax, string $imagePath):ProductEntity{
$product = new ProductEntity();
$product->setName($name);
$product->setColor($color);
$euro = new Euro();
$euro->setCents($cents);
$price = new Price();
$price->setPrice($euro);
$price->setTax($tax);
$product->setPrice($price);
$image = new UrlImage();
$image->setImage($imagePath);
$product->setImage($image);
return $product;
}
public function deleteAllProducts(): void
{}