/** * @param \Secretary\Entity\Key $key * @param \Secretary\Entity\User $user * @return \Secretary\Entity\Key */ public function saveKey(KeyEntity $key, UserEntity $user, $pubKey) { $key->setPubKey($pubKey); $key->setUserId($user->getId()); $key->setUser($user); $this->em->persist($key); $this->em->flush(); return $key; }