/** * Add invitation into db * * @author Hrayr Shahbazyan * @param array $data * @return int */ public function addInvitation(array $data) { //Get entity manager $em = $this->getEntityManager(); //Get the entity $invitation = new \Company\Entity\Invitation(); //Populate the Invitation's entity $invitation->setUser($this->getServiceLocator()->get('user.service')->getUserById($data['user_id']))->setGroup($this->getServiceLocator()->get('group.service')->getGroupById($data['group_id']))->setUserEmail($data['user_email']); $em->persist($invitation); $em->flush(); return $invitation->getId(); }