/** * Delete a category. Only delete a category if it is not protected */ public function delete() { // Get any articles using this category $articles = News::fetchIdsFrom("category", $this->getId(), 'i'); // Only delete a category if it is not protected and is not being used if (!$this->isProtected() && count($articles) == 0) { parent::delete(); } }