1
0
mirror of synced 2025-02-20 22:23:14 +03:00

[2.0] added Collection object creation

This commit is contained in:
piccoloprincipe 2009-07-02 07:47:24 +00:00
parent 76661cd987
commit 0f2499f93b
3 changed files with 25 additions and 10 deletions

View File

@ -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;
}
}

View File

@ -41,11 +41,6 @@ class ECommerceCustomer
$this->name = $name;
}
/**
* @OneToMany(targetEntity="ECommerceProduct")
public $watched;
*/
public function setCart(ECommerceCart $cart)
{
if ($this->cart !== $cart) {

View File

@ -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;
}