当前位置: 首页>>代码示例>>PHP>>正文


PHP Constraint::getMessage方法代码示例

本文整理汇总了PHP中Symfony\Component\Validator\Constraint::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Constraint::getMessage方法的具体用法?PHP Constraint::getMessage怎么用?PHP Constraint::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Validator\Constraint的用法示例。


在下文中一共展示了Constraint::getMessage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 public function validate($commitEntity, Constraint $constraint)
 {
     $statusHash = $commitEntity->getStatusHash();
     $this->projectEnvironment = $this->projectEnvironmentStorage->getProjectEnviromment($commitEntity->getProject());
     $this->gitStatusCommand->overRideGitEnvironment($this->projectEnvironment);
     $currentStatusHash = $this->gitStatusCommand->getStatusHash();
     if ($currentStatusHash !== $statusHash) {
         $this->context->buildViolation($constraint->getMessage())->setParameter('{{statushash}}', $statusHash)->setParameter('{{currentstatushash}}', $currentStatusHash)->atPath('files')->addViolation();
     }
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:10,代码来源:StatusHashValidator.php

示例2: validate

 /**
  * 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') === true) {
                 $this->context->buildViolation($constraint->getMessage())->atPath('path')->addViolation();
             }
         } catch (SshLoginException $sshLoginException) {
             $this->context->buildViolation($sshLoginException->getMessage())->atPath('path')->addViolation();
         } catch (Exception $ex) {
             $this->context->buildViolation($ex->getMessage())->atPath('path')->addViolation();
         }
     } else {
         if (file_exists($gitPath . '/.git') === true) {
             $this->context->buildViolation($constraint->getMessage())->atPath('path')->addViolation();
         }
     }
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:26,代码来源:GitFolderNotExistsValidator.php

示例3: validate

 /**
  * 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();
         }
     }
 }
开发者ID:sshversioncontrol,项目名称:git-web-client,代码行数:22,代码来源:SshDetailsValidator.php

示例4: isValid

 /**
  * @param object $object
  * @param \Symfony\Component\Validator\Constraint $constraint
  * @return Boolean
  */
 public function isValid($object, Constraint $constraint)
 {
     if (!is_array($constraint->fields) && !is_string($constraint->fields)) {
         throw new UnexpectedTypeException($constraint->fields, 'array');
     }
     $fields = (array) $constraint->fields;
     if (0 === count($fields)) {
         throw new ConstraintDefinitionException("At least one field must be specified.");
     }
     $class = get_class($object);
     $peerClass = $class . 'Peer';
     $queryClass = $class . 'Query';
     $classFields = $peerClass::getFieldNames(\BasePeer::TYPE_FIELDNAME);
     foreach ($fields as $fieldName) {
         if (false === array_search($fieldName, $classFields)) {
             throw new ConstraintDefinitionException('The field "' . $fieldName . '" doesn\'t exist in the "' . $class . '" class.');
         }
     }
     $bddUsersQuery = $queryClass::create();
     foreach ($fields as $fieldName) {
         $bddUsersQuery->filterBy($peerClass::translateFieldName($fieldName, \BasePeer::TYPE_FIELDNAME, \BasePeer::TYPE_PHPNAME), $object->getByName($fieldName, \BasePeer::TYPE_FIELDNAME));
     }
     $bddUsers = $bddUsersQuery->find();
     $countUser = count($bddUsers);
     if ($countUser > 1 || $countUser === 1 && $object !== $bddUsers[0]) {
         $constraintMessage = $constraint->getMessage();
         $constraintMessage .= ' with';
         foreach ($fields as $fieldName) {
             $constraintMessage .= sprintf(' %s "%s" and', $peerClass::translateFieldName($fieldName, \BasePeer::TYPE_FIELDNAME, \BasePeer::TYPE_PHPNAME), $object->getByName($fieldName, \BasePeer::TYPE_FIELDNAME));
         }
         $constraintMessage = substr($constraintMessage, 0, -4) . '.';
         $this->setMessage($constraintMessage);
         return false;
     }
     return true;
 }
开发者ID:angelk,项目名称:PropelBundle,代码行数:41,代码来源:UniqueObjectValidator.php

示例5: validate

 /**
  * @param mixed $value
  * @param Constraint $constraint
  * @throws \Exception
  */
 public function validate($value, Constraint $constraint)
 {
     if (!preg_match('#https?://www\\.youtube\\.com/watch\\?v=([^&]*)#', $value, $matches)) {
         $this->context->addViolation($constraint->getMessage());
     }
 }
开发者ID:w3build,项目名称:media-bundle,代码行数:11,代码来源:YouTubeValidator.php

示例6: addViolation

 /**
  * Add a violation.
  *
  * @param mixed      $value      The value that should be validated.
  * @param Constraint $constraint The constraint for the validation.
  */
 private function addViolation($value, Constraint $constraint)
 {
     $this->context->addViolation($constraint->getMessage(), array('{{ type }}' => $constraint->getType(), '{{ value }}' => $value));
 }
开发者ID:clavier-souris,项目名称:phone-number-bundle,代码行数:10,代码来源:PhoneNumberValidator.php


注:本文中的Symfony\Component\Validator\Constraint::getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。