public function saveObjects($data, $manager) { // type object $object = new Project(); // fields object $object->setName($data['name']); $object->setStatus($data['status']); $object->setFolder($data['folder']); $object->setHerokuGit($data['herokuGit']); $object->setHerokuHttp($data['herokuHttp']); $object->setHerokuIdentifier($data['herokuIdentifier']); $object->setGitHubRepositoryName($data['gitHubRepositoryName']); // refs $object->setServer($this->getReference($data['ref-server'])); $object->setRequisite($this->getReference($data['ref-requisite'])); //$object->addUser($this->getReference($data['ref-user'])); // persist $manager->persist($object); $userProject = new UserProject(); $userProject->setUser($this->getReference($data['ref-user'])); $userProject->setProject($object); $manager->persist($userProject); $manager->flush(); // add his ref $this->addReference($data['ref-self'], $object); }