public function remove(Category $category) { if ($category->hasProducts()) { throw new EntityCannotBeDeletedException('Category has products.'); } foreach ($category->getSubcategories() as $subcategory) { $this->remove($subcategory); } $this->removeEntity($category); }
public function isDirectlyInCategory(Category $category) { foreach ($category->getSubcategories() as $subcategory) { if ($this->belongsIntoCategory($subcategory)) { return false; } } return true; }