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);
 }
 /**
  * start/create project for requisite
  *
  * @param $requisite_id
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function startAction($requisite_id)
 {
     $em = $this->getDoctrine()->getManager();
     $requisite = $this->getDoctrine()->getRepository('AppBundle:Requisite')->find($requisite_id);
     $project = $requisite->getProject();
     if ($project) {
         throw new NotFoundHttpException('Requisite already have project');
     }
     $project = new Project();
     $project->setRequisite($requisite);
     $project->setStatus(0);
     $projecter = $this->get('projecter');
     // heroky app create
     $herokuResponse = $projecter->buildHerokuProject(false, $requisite->getUser()->getHerokuApiToken());
     // github create repository
     $loginString = $requisite->getUser()->getGitHubAccountUser() . ":" . $requisite->getUser()->getGitHubAccountPassword();
     $projecter->createGitHubRepository($herokuResponse["name"], $loginString);
     // Create auhtorization token
     $gitHubToken = $projecter->createGitHubToken($loginString);
     $herokuToken = $projecter->createHerokuToken($requisite->getUser()->getHerokuApiToken());
     // create webhooks Auto-Deploy
     $projecter->createGitHubHookAutoDeployForRepository($herokuResponse["name"], $gitHubToken, $loginString);
     // create webhooks HerokuBeta
     $projecter->createGitHubHerokuBetaForRepository($herokuResponse["name"], $gitHubToken, $herokuToken, $loginString);
     // set fields entity
     $project->setHerokuIdentifier($herokuResponse["id"]);
     $project->setHerokuGit($herokuResponse["git_url"]);
     $project->setHerokuHttp($herokuResponse["web_url"]);
     $project->setName($herokuResponse["name"]);
     $project->setGitHubToken($gitHubToken);
     $project->setHerokuToken($herokuToken);
     $project->setGitHubRepositoryName($herokuResponse["name"]);
     // UserProject
     $userProject = new UserProject();
     $userProject->setProject($project);
     $userProject->setUser($this->getUser());
     $em->persist($userProject);
     $em->persist($project);
     $em->flush();
     return $this->redirectToRoute('project_list');
 }