public function findById($id) { if (!($entity = $this->categoryRepository->findCategoryById($id))) { throw new CategoryIdNotFoundException($id); } return $entity; }