Example #1
0
 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);
 }
Example #2
0
 public function isDirectlyInCategory(Category $category)
 {
     foreach ($category->getSubcategories() as $subcategory) {
         if ($this->belongsIntoCategory($subcategory)) {
             return false;
         }
     }
     return true;
 }