[2.0] added Collection object creation
This commit is contained in:
parent
76661cd987
commit
0f2499f93b
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user