private function karmaAction($user, $action) { $history = new History(); if ($action === 'up') { $user->setKarma($user->getKarma() + 1); $history->setAction(true); } else { $user->setKarma($user->getKarma() - 1); $history->setAction(false); } $history->setUser($user); $history->setAuthor($this->getUser()); $this->getUser()->addHistoryByUser($history); $user->addHistory($history); $em = $this->getDoctrine()->getManager(); $em->persist($history); $em->persist($user); $em->flush(); }