[2.0] simplified removing code
This commit is contained in:
parent
1b9b6c68e0
commit
3f4cd46b96
@ -59,9 +59,9 @@ class ECommerceCategory
|
|||||||
|
|
||||||
public function removeProduct(ECommerceProduct $product)
|
public function removeProduct(ECommerceProduct $product)
|
||||||
{
|
{
|
||||||
if ($this->products->contains($product)) {
|
$removed = $this->products->removeElement($product);
|
||||||
$this->products->removeElement($product);
|
if ($removed !== null) {
|
||||||
$product->removeCategory($this);
|
$removed->removeCategory($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,12 +98,10 @@ 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;
|
||||||
}
|
}
|
||||||
@ -118,9 +116,9 @@ class ECommerceProduct
|
|||||||
|
|
||||||
public function removeCategory(ECommerceCategory $category)
|
public function removeCategory(ECommerceCategory $category)
|
||||||
{
|
{
|
||||||
if ($this->categories->contains($category)) {
|
$removed = $this->categories->removeElement($category);
|
||||||
$this->categories->removeElement($category);
|
if ($removed !== null) {
|
||||||
$category->removeProduct($this);
|
$removed->removeProduct($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user