Commit 0f2499f9 authored by piccoloprincipe's avatar piccoloprincipe

[2.0] added Collection object creation

parent 76661cd9
...@@ -20,7 +20,7 @@ class ECommerceCart ...@@ -20,7 +20,7 @@ class ECommerceCart
private $id; private $id;
/** /**
* @Column(type="string", length=50) * @Column(type="string", length=50, nullable=true)
*/ */
private $payment; private $payment;
...@@ -38,6 +38,11 @@ class ECommerceCart ...@@ -38,6 +38,11 @@ class ECommerceCart
*/ */
private $products; private $products;
public function __construct()
{
$this->products = new \Doctrine\Common\Collections\Collection;
}
public function getId() { public function getId() {
return $this->id; return $this->id;
} }
...@@ -69,4 +74,12 @@ class ECommerceCart ...@@ -69,4 +74,12 @@ class ECommerceCart
return $this->customer; return $this->customer;
} }
public function getProducts()
{
return $this->products;
}
public function addProduct(ECommerceProduct $product) {
$this->products[] = $product;
}
} }
...@@ -41,11 +41,6 @@ class ECommerceCustomer ...@@ -41,11 +41,6 @@ class ECommerceCustomer
$this->name = $name; $this->name = $name;
} }
/**
* @OneToMany(targetEntity="ECommerceProduct")
public $watched;
*/
public function setCart(ECommerceCart $cart) public function setCart(ECommerceCart $cart)
{ {
if ($this->cart !== $cart) { if ($this->cart !== $cart) {
......
...@@ -43,6 +43,11 @@ class ECommerceProduct ...@@ -43,6 +43,11 @@ class ECommerceProduct
private $categories; private $categories;
*/ */
public function __construct()
{
$this->features = new \Doctrine\Common\Collections\Collection;
}
public function getId() public function getId()
{ {
return $this->id; return $this->id;
...@@ -89,11 +94,13 @@ class ECommerceProduct ...@@ -89,11 +94,13 @@ class ECommerceProduct
} }
public function removeFeature(ECommerceFeature $feature) { public function removeFeature(ECommerceFeature $feature) {
if ($this->features->contains($feature)) {
$removed = $this->features->removeElement($feature); $removed = $this->features->removeElement($feature);
if ($removed !== null) { if ($removed) {
$removed->removeProduct(); $feature->removeProduct();
return true; return true;
} }
}
return false; return false;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment