/**
  * Form to choose which brabch and remote a user will pull.
  * This is just the form. Also see pullToLocal().
  *
  * @Route("/", name="project_listremote")
  * @Method("GET")
  * @Template()
  * @ProjectAccess(grantType="MASTER")
  */
 public function listAction($id)
 {
     $gitRemoteVersions = array();
     try {
         $gitRemoteVersions = $this->gitSyncCommands->getRemoteVersions();
     } catch (\Exception $e) {
         $this->get('session')->getFlashBag()->add('error', $e->getMessage());
     }
     return array_merge($this->viewVariables, array('remotes' => $gitRemoteVersions, 'branchName' => $this->branchName));
 }
 /**
  * Creates a form to edit a Project entity.
  *
  * @param Project $project The entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createPushPullForm($project, $formAction = 'project_pushremote')
 {
     //Remote Server choice
     $gitRemoteVersions = $this->gitSyncCommands->getRemoteVersions();
     $remoteChoices = array();
     foreach ($gitRemoteVersions as $remoteVersion) {
         $remoteChoices[$remoteVersion[0] . '(' . $remoteVersion[1] . ')'] = $remoteVersion[0];
     }
     //Local Branch choice
     $branches = $this->gitCommands->command('branch')->getBranches(true);
     $branchChoices = array();
     foreach ($branches as $branchName) {
         $branchChoices[$branchName] = $branchName;
     }
     //Current branch
     $currentBranch = $this->gitCommands->command('branch')->getCurrentBranch();
     $firstOrigin = reset($remoteChoices);
     $defaultData = array('branch' => $currentBranch);
     $form = $this->createFormBuilder($defaultData, array('action' => $this->generateUrl($formAction, array('id' => $project->getId())), 'method' => 'POST'))->add('remote', ChoiceType::class, array('label' => 'Remote Server', 'choices' => $remoteChoices, 'data' => $firstOrigin, 'required' => false, 'choices_as_values' => true, 'constraints' => array(new NotBlank())))->add('branch', ChoiceType::class, array('label' => 'Branch', 'choices' => $branchChoices, 'preferred_choices' => array($currentBranch), 'data' => trim($currentBranch), 'required' => false, 'choices_as_values' => true, 'constraints' => array(new NotBlank())))->getForm();
     //$form->add('submitMain', SubmitType::class, array('label' => 'Push'));
     return $form;
 }