/** * Deletes the given category. All articles are moved to the standard category. * @param ArticleRepository $articleRepo Repo for moving the articles. * @param Category $category The category that must be deleted. * @throws NotFoundException If this category doesn't exist in the database. * @throws PDOException If a database error occurs. * @throws InvalidArgumentException If the category is a standard category. */ public function deleteCategory(ArticleRepository $articleRepo, Category $category) { if ($category->isStandardCategory()) { throw new InvalidArgumentException("cannot delete standard category"); } $articleRepo->changeCategories($category->getId(), 1); $this->where($this->idField, '=', $category->getId())->deleteOneOrFail(); }