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


PHP ExecutionContextInterface::addViolationAt方法代码示例

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


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

示例1: isValidUppMsgType

 /**
  * @param ExecutionContextInterface $context
  */
 public function isValidUppMsgType(ExecutionContextInterface $context)
 {
     $uppMsgType = $this->getUppMsgType();
     if (self::MSGTYPE_GET !== $uppMsgType) {
         $context->addViolationAt('status', "Invalid uppMsgType '{$uppMsgType}' given!");
     }
 }
开发者ID:ibrows,项目名称:datatrans,代码行数:10,代码来源:CancelAuthorizationResponse.php

示例2: isSettingsValid

 /**
  * Validate settings.
  *
  * @param ExecutionContext $context
  */
 public function isSettingsValid(ExecutionContextInterface $context)
 {
     foreach ($this->getSettings() as $value) {
         if (is_array($value)) {
             $context->addViolationAt('settings', 'A multidimensional array is not allowed, only use key-value pairs.');
         }
     }
 }
开发者ID:symfony-cmf,项目名称:block-bundle,代码行数:13,代码来源:AbstractBlock.php

示例3: isNiveauValid

 /**
  * @Assert\Callback()
  * @param ExecutionContextInterface $context
  */
 public function isNiveauValid(ExecutionContextInterface $context)
 {
     if ((int) $this->niveau >= count(self::getNiveaux())) {
         // La règle est violée, on définit l'erreur et son message
         // 1er argument : on dit quel attribut l'erreur concerne, ici « contenu »
         // 2e argument : le message d'erreur
         $context->addViolationAt('niveau', sprintf('Niveau invalide, il doit être parmis "%s".', implode(', ', self::getNiveaux())));
     }
 }
开发者ID:tvequaud,项目名称:SdzBlog,代码行数:13,代码来源:ArticleCompetence.php

示例4: validate

 /**
  * Validates contact method
  *
  * @param ContactRequest            $object
  * @param ExecutionContextInterface $context
  */
 public static function validate(ContactRequest $object, ExecutionContextInterface $context)
 {
     $emailError = $phoneError = false;
     switch ($object->getPreferredContactMethod()) {
         case ContactRequest::CONTACT_METHOD_PHONE:
             $phoneError = !$object->getPhone();
             break;
         case ContactRequest::CONTACT_METHOD_EMAIL:
             $emailError = !$object->getEmailAddress();
             break;
         case ContactRequest::CONTACT_METHOD_BOTH:
         default:
             $phoneError = !$object->getPhone();
             $emailError = !$object->getEmailAddress();
     }
     if ($emailError) {
         $context->addViolationAt('emailAddress', 'This value should not be blank.');
     }
     if ($phoneError) {
         $context->addViolationAt('phone', 'This value should not be blank.');
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:28,代码来源:ContactRequestCallbackValidator.php

示例5: addViolation

 /**
  * @param string|array $message
  * @param array        $parameters
  * @param null         $value
  *
  * @return ErrorElement
  */
 public function addViolation($message, $parameters = array(), $value = null)
 {
     if (is_array($message)) {
         $value = isset($message[2]) ? $message[2] : $value;
         $parameters = isset($message[1]) ? (array) $message[1] : array();
         $message = isset($message[0]) ? $message[0] : 'error';
     }
     $subPath = (string) $this->getCurrentPropertyPath();
     if ($this->context instanceof LegacyExecutionContextInterface) {
         $this->context->addViolationAt($subPath, $message, $parameters, $value);
     } else {
         $this->context->buildViolation($message)->atPath($subPath)->setParameters($parameters)->setInvalidValue($value)->addViolation();
     }
     $this->errors[] = array($message, $parameters, $value);
     return $this;
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:23,代码来源:ErrorElement.php

示例6: validatePassword

 /**
  * Si es un user nuevo el password debe ser obligatorio.
  *
  * @param ExecutionContextInterface $ec Contexto de Ejecuci..n.
  *
  * @return void
  */
 public function validatePassword(ExecutionContextInterface $ec)
 {
     $plainPassword = $this->getPlainPassword();
     if (!$this->id && empty($plainPassword)) {
         $ec->addViolationAt('plainPassword', 'La contraseña no debe estar vacía.');
     }
 }
开发者ID:bouna7,项目名称:UserBundle,代码行数:14,代码来源:User.php

示例7: validateEntity

 /**
  * @param ExecutionContextInterface $context
  */
 public function validateEntity(ExecutionContextInterface $context)
 {
     if ($this->getType() == self::TYPE_PAGE_LINK && !$this->getNodeTranslation()) {
         $context->addViolationAt('nodeTranslation', 'Please select a page');
     } elseif ($this->getType() == self::TYPE_URL_LINK) {
         if (strlen($this->getTitle()) == 0) {
             $context->addViolationAt('title', 'Please set the link title');
         }
         if (strlen($this->getUrl()) == 0) {
             $context->addViolationAt('url', 'Please set the link URL');
         }
     }
 }
开发者ID:n8green,项目名称:KunstmaanBundlesCMS,代码行数:16,代码来源:BaseMenuItem.php

示例8: isValidReqType

 /**
  * @param ExecutionContextInterface $context
  */
 public function isValidReqType(ExecutionContextInterface $context)
 {
     $reqType = $this->getReqType();
     if (!in_array($reqType, array_keys(\Dominikzogg\ClassHelpers\getConstantsWithPrefix(__CLASS__, 'REQTYPE_')))) {
         $context->addViolationAt('status', "Unknown reqType '{$reqType}' given!");
     }
 }
开发者ID:ibrows,项目名称:datatrans,代码行数:10,代码来源:FailedAuthorizationResponse.php

示例9: isDataFieldValid

 /**
  * @Assert\Callback
  */
 public function isDataFieldValid(ExecutionContextInterface $context)
 {
     //TODO: why is it not working?
     $context->addViolationAt('textValue', 'Haaaaha', array(), null);
 }
开发者ID:theus77,项目名称:ElasticMS,代码行数:8,代码来源:DataField.php

示例10: forbiddenWords

 /**
  * @Assert\Callback
  */
 public function forbiddenWords(ExecutionContextInterface $context)
 {
     $forbiddenWords = array('branches', 'details', 'activity', 'default');
     if (in_array($this->branchId, $forbiddenWords)) {
         $context->addViolationAt('branchId', 'Branch ID is a forbidden word ("' . $this->branchId . '") !', array(), null);
     }
 }
开发者ID:ngld,项目名称:hlp-nebula,代码行数:10,代码来源:Branch.php

示例11: forbiddenWords

 /**
  * @Assert\Callback
  * Need to change this to avoid team name duplicates
  */
 public function forbiddenWords(ExecutionContextInterface $context)
 {
     $forbiddenWords = array('test');
     if (in_array($this->usernameCanonical, $forbiddenWords)) {
         $context->addViolationAt('usernameCanonical', 'Username is a forbidden word ("' . $this->usernameCanonical . '") !', array(), null);
     }
 }
开发者ID:ngld,项目名称:hlp-nebula,代码行数:11,代码来源:User.php

示例12: isValidStatus

 /**
  * @param ExecutionContextInterface $context
  */
 public function isValidStatus(ExecutionContextInterface $context)
 {
     $status = $this->getStatus();
     if (!in_array($status, array_keys(\Dominikzogg\ClassHelpers\getConstantsWithPrefix(__CLASS__, 'RESPONSESTATUS_')))) {
         $context->addViolationAt('status', "Unknown status '{$status}' given!");
     }
 }
开发者ID:ibrows,项目名称:datatrans,代码行数:10,代码来源:AbstractAuthorizationResponse.php

示例13: contenuValide

 /**
  * @Assert\Callback
  */
 public function contenuValide(ExecutionContextInterface $context)
 {
     $mots_interdits = array('échec', 'abandon');
     // On vérifie que le contenu ne contient pas l'un des mots
     if (preg_match('#' . implode('|', $mots_interdits) . '#', $this->getContenu())) {
         // La règle est violée, on définit l'erreur et son message
         // 1er argument : on dit quel attribut l'erreur concerne, ici « contenu »
         // 2e argument : le message d'erreur
         $context->addViolationAt('contenu', 'Contenu invalide car il contient un mot interdit.', array(), null);
     }
 }
开发者ID:tvequaud,项目名称:SdzBlog,代码行数:14,代码来源:Article.php

示例14: isValidExpy

 /**
  * @param ExecutionContextInterface $context
  */
 public function isValidExpy(ExecutionContextInterface $context)
 {
     $expy = $this->getExpy();
     $now = new \DateTime();
     $years = array();
     for ($i = 0; $i < 10; $i++) {
         $years[] = $now->format('y');
         $now->modify('+1year');
     }
     if (!in_array($expy, $years, true)) {
         $context->addViolationAt('expy', "Invalid expy '{$expy}' given!");
     }
 }
开发者ID:ibrows,项目名称:datatrans,代码行数:16,代码来源:HiddenAuthorizationRequestWithCardNo.php

示例15: validate

 /**
  * @Assert\Callback(groups={"suscribe"})
  * use Symfony\Component\Validator\Context\ExecutionContextInterface;
  */
 public function validate(ExecutionContextInterface $context)
 {
     $val = $this->getUsername();
     if (!empty($val)) {
         if ($this->getUsername() == $this->getPassword()) {
             $context->addViolationAt('username', 'Votre login ne doit pas être identique à votre mot de passe', array(), null);
         }
     }
     $val = $this->getEmail();
     if (!empty($val)) {
         if ($this->getUsername() == $this->getEmail()) {
             $context->addViolationAt('email', 'Votre email ne doit pas être identique à votre login', array(), null);
         }
     }
 }
开发者ID:unpetitlu,项目名称:store,代码行数:19,代码来源:Jeweler.php


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