Commit 0f2499f9 authored by piccoloprincipe's avatar piccoloprincipe

[2.0] added Collection object creation

parent 76661cd9
......@@ -20,7 +20,7 @@ class ECommerceCart
private $id;
/**
* @Column(type="string", length=50)
* @Column(type="string", length=50, nullable=true)
*/
private $payment;
......@@ -37,6 +37,11 @@ class ECommerceCart
inverseJoinColumns={{"name"="product_id", "referencedColumnName"="id"}})
*/
private $products;
public function __construct()
{
$this->products = new \Doctrine\Common\Collections\Collection;
}
public function getId() {
return $this->id;
......@@ -69,4 +74,12 @@ class ECommerceCart
return $this->customer;
}
public function getProducts()
{
return $this->products;
}
public function addProduct(ECommerceProduct $product) {
$this->products[] = $product;
}
}
......@@ -41,11 +41,6 @@ class ECommerceCustomer
$this->name = $name;
}
/**
* @OneToMany(targetEntity="ECommerceProduct")
public $watched;
*/
public function setCart(ECommerceCart $cart)
{
if ($this->cart !== $cart) {
......
......@@ -43,6 +43,11 @@ class ECommerceProduct
private $categories;
*/
public function __construct()
{
$this->features = new \Doctrine\Common\Collections\Collection;
}
public function getId()
{
return $this->id;
......@@ -89,10 +94,12 @@ class ECommerceProduct
}
public function removeFeature(ECommerceFeature $feature) {
$removed = $this->features->removeElement($feature);
if ($removed !== null) {
$removed->removeProduct();
return true;
if ($this->features->contains($feature)) {
$removed = $this->features->removeElement($feature);
if ($removed) {
$feature->removeProduct();
return true;
}
}
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