示例#1
0
 /**
  * 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);
 }
示例#2
0
 /**
  * @return mixed
  */
 public function getCategories()
 {
     return $this->eventCategoryRepository->findAll();
 }