1
0
mirror of synced 2025-03-21 07:23:55 +03:00

[2.0] simplified removing code

This commit is contained in:
piccoloprincipe 2009-07-02 09:44:06 +00:00
parent 1b9b6c68e0
commit 3f4cd46b96
2 changed files with 10 additions and 12 deletions

View File

@ -59,9 +59,9 @@ class ECommerceCategory
public function removeProduct(ECommerceProduct $product)
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
$product->removeCategory($this);
$removed = $this->products->removeElement($product);
if ($removed !== null) {
$removed->removeCategory($this);
}
}

View File

@ -98,12 +98,10 @@ class ECommerceProduct
public function removeFeature(ECommerceFeature $feature)
{
if ($this->features->contains($feature)) {
$removed = $this->features->removeElement($feature);
if ($removed) {
$feature->removeProduct();
return true;
}
$removed = $this->features->removeElement($feature);
if ($removed !== null) {
$removed->removeProduct();
return true;
}
return false;
}
@ -118,9 +116,9 @@ class ECommerceProduct
public function removeCategory(ECommerceCategory $category)
{
if ($this->categories->contains($category)) {
$this->categories->removeElement($category);
$category->removeProduct($this);
$removed = $this->categories->removeElement($category);
if ($removed !== null) {
$removed->removeProduct($this);
}
}