public static function addCostCategory($em, $parameters) { $costCategory = new CostCategory(); $costCategory->setName($parameters->name); $costCategory->setType($parameters->type); $em->persist($costCategory); $em->flush(); return $costCategory; }