/**
  * @param int $id
  */
 public function initAction($id, $grantType = 'VIEW')
 {
     $em = $this->getDoctrine()->getManager();
     $this->project = $em->getRepository('VersionControlGitControlBundle:Project')->find($id);
     if (!$this->project) {
         throw $this->createNotFoundException('Unable to find Project entity.');
     }
     //Redirect is not ajax
     $request = $this->container->get('request_stack')->getCurrentRequest();
     //Do not redirect if in test mode
     if ($this->ajaxOnly == true && !$request->isXmlHttpRequest() && $this->container->getParameter('kernel.environment') != 'test') {
         return $this->generateUrl('project', array('section' => urlencode($request->getRequestUri())));
     }
     $this->checkProjectAuthorization($this->project, $grantType);
     $projectEnvironment = $this->getProjectEnvironment();
     $this->gitCommands = $this->get('version_control.git_commands')->setGitEnvironment($projectEnvironment);
     $this->branchName = $this->gitCommands->command('branch')->getCurrentBranch();
     $this->viewVariables = array_merge($this->viewVariables, array('project' => $this->project, 'branchName' => $this->branchName));
 }