/** * Deletes a category with a given id. * * @param int $id the id of the category to delete * * @throws EntityNotFoundException */ public function delete($id) { $categoryEntity = $this->categoryRepository->findCategoryById($id); if (!$categoryEntity) { throw new EntityNotFoundException('SuluCategoryBundle:Category', $id); } $this->em->remove($categoryEntity); $this->em->flush(); // throw a category.delete event $event = new CategoryDeleteEvent($categoryEntity); $this->eventDispatcher->dispatch(CategoryEvents::CATEGORY_DELETE, $event); }
/** * @return mixed */ public function getCategories() { return $this->eventCategoryRepository->findAll(); }