/**
  * Validates Project Enviroment.
  *
  * @param VersionControl\GitControlBundle\Entity\ProjectEnvironment $projectEnvironment
  * @param Constraint                                                $constraint
  */
 public function validate($projectEnvironment, Constraint $constraint)
 {
     $gitPath = rtrim(trim($projectEnvironment->getPath()), '/');
     if ($projectEnvironment->getSsh() === true) {
         $this->sftpProcess->setGitEnviroment($projectEnvironment);
         try {
             if ($this->sftpProcess->isDir($gitPath) === false) {
                 $this->context->buildViolation('This directory (%gitPath%) does not exist. Please check that you have entered the correct path in %projectEnviromentTitle%')->setParameter('%gitPath%', $gitPath)->setParameter('%projectEnviromentTitle%', $projectEnvironment->getTitle())->atPath('path')->addViolation();
             }
         } catch (SshLoginException $sshLoginException) {
             $this->context->buildViolation($sshLoginException->getMessage())->atPath('title')->addViolation();
         } catch (\Exception $ex) {
             $this->context->buildViolation($constraint->getMessage())->atPath('title')->addViolation();
         }
     }
 }
 /**
  * Validates Project Enviroment.
  *
  * @param VersionControl\GitControlBundle\Entity\ProjectEnvironment $projectEnvironment
  * @param Constraint                                                $constraint
  */
 public function validate($projectEnvironment, Constraint $constraint)
 {
     $gitPath = rtrim(trim($projectEnvironment->getPath()), '/');
     if ($projectEnvironment->getSsh() === true) {
         $this->sftpProcess->setGitEnviroment($projectEnvironment);
         try {
             if ($this->sftpProcess->fileExists($gitPath . '/.git') === false) {
                 $this->context->buildViolation($constraint->getMessage())->atPath('path')->addViolation();
             }
         } catch (SshLoginException $sshLoginException) {
             $this->context->buildViolation($sshLoginException->getMessage())->atPath('path')->addViolation();
         } catch (\Exception $e) {
             $this->context->buildViolation($e->getMessage())->atPath('path')->addViolation();
         }
     } else {
         if (file_exists($gitPath . '/.git') === false) {
             $this->context->buildViolation($constraint->message)->atPath('path')->addViolation();
         }
     }
 }