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


PHP ExecutionContextInterface::addViolationAt方法代码示例

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


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

示例1: validate

 /**
  * @Assert\Callback
  */
 public function validate(ExecutionContextInterface $context)
 {
     // Vérifie si le nom est bidon
     if ($this->getDebut() > $this->getFin()) {
         $context->addViolationAt('fin', 'La date de début ne peut être postérieure à la date de fin');
     }
     $datesysteme = new \Datetime();
     if ($this->getFin() < $datesysteme) {
         $context->addViolationAt('fin', 'La date de fin ne peut être antérieure à la date du jour');
     }
 }
开发者ID:FARIDMESCAM,项目名称:Manufacture,代码行数:14,代码来源:Demande.php

示例2: checkEndDate

 /**
  * Validation function for optional constraints
  *
  * @param RentRecoveryPlusCancellation $cancellation
  * @param ExecutionContextInterface $context
  */
 public function checkEndDate($cancellation, ExecutionContextInterface $context)
 {
     $expiresAt = new \DateTime($cancellation->getPolicyExpiresAt());
     $endAt = new \DateTime($cancellation->getPolicyEndAt());
     $now = new \DateTime();
     $now->setTime(0, 0, 0);
     if ($endAt > $expiresAt) {
         $context->addViolationAt('policyEndAt', 'Requested date exceeds existing end date of ' . $expiresAt->format('d-m-Y'), array(), null);
     } else {
         if ($endAt < $now) {
             $context->addViolationAt('policyEndAt', 'Requested date is in the past', array(), null);
         }
     }
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:20,代码来源:RentRecoveryPlusCancellationType.php

示例3: checkAtLeastOnePhoneNumberIsDefined

 public function checkAtLeastOnePhoneNumberIsDefined($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (empty($data["phone"]) && empty($data["cellphone"])) {
         $context->addViolationAt("phone", Translator::getInstance()->trans("Please enter a home or mobile phone number"));
     }
 }
开发者ID:thelia-modules,项目名称:ForcePhone,代码行数:7,代码来源:ForcePhoneEventListener.php

示例4: isSubjectValid

 public function isSubjectValid(ExecutionContextInterface $context)
 {
     $text = preg_replace(array('/<a[^>]+href[^>]+>/', '/<\\/a>/'), '', $this->subjectParsed);
     if (mb_strlen($text, 'utf-8') > 500) {
         $context->addViolationAt('subject', 'The subject too long');
     }
 }
开发者ID:shakaran,项目名称:powerline-server,代码行数:7,代码来源:LeaderNews.php

示例5: isValid

 public function isValid(ExecutionContextInterface $context)
 {
     $is_valid = $this->start <= $this->end;
     if (!$is_valid) {
         $context->addViolationAt('end', 'bladetester_calendar.validation.event_dates', array(), null);
     }
 }
开发者ID:stephylee,项目名称:calendar-bundle,代码行数:7,代码来源:Event.php

示例6: isVoteValid

 /**
  * {@inheritdoc}
  */
 public function isVoteValid(ExecutionContextInterface $context)
 {
     if (!$this->checkValue($this->value)) {
         $message = 'A vote cannot have a 0 value';
         $propertyPath = $context->getPropertyPath() . '.value';
         $context->addViolationAt($propertyPath, $message);
     }
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:11,代码来源:Vote.php

示例7: 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:nvbooster,项目名称:BlockBundle,代码行数:13,代码来源:AbstractBlock.php

示例8: addViolation

 /**
  * {@inheritdoc}
  */
 public function addViolation()
 {
     if ($this->propertyPath) {
         $this->context->addViolationAt($this->propertyPath, $this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code);
         return;
     }
     $this->context->addViolation($this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code);
 }
开发者ID:iurkidi,项目名称:nmarcajunto,代码行数:11,代码来源:LegacyConstraintViolationBuilder.php

示例9: isNiveauValid

 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:sorani-dev,项目名称:SdzBlog,代码行数:9,代码来源:ArticleCompetence.php

示例10: isCorrectRequiredFields

 public function isCorrectRequiredFields(ExecutionContextInterface $context)
 {
     if ($this->group->getFillFieldsRequired()) {
         $groupFieldsIds = $this->group->getFieldsIds();
         $userFieldsIds = $this->getFieldsIds();
         if (!empty(array_diff($groupFieldsIds, $userFieldsIds))) {
             $context->addViolationAt('fields', 'Please to fill required fields', array(), null);
         }
     }
 }
开发者ID:shakaran,项目名称:powerline-server,代码行数:10,代码来源:Worksheet.php

示例11: contenuValide

 public function contenuValide(ExecutionContextInterface $context)
 {
     $mots_interdits = array('échec', 'abandon');
     // On verfie que le contenu ne contient pas l'un des mots
     if (preg_match('#' . implode('|', $mots_interdits) . '#', $this->getContenu())) {
         //La regle est violé, on definit le l'erreur et son message
         // 1 er argument : on dit quel attribut l'erreur concerne, ici <<contenu >>
         // 2 e argument : le message d'erreur
         $context->addViolationAt('contenu', 'Contenu invalide car il contient un mot inderdit, array(), null');
     }
 }
开发者ID:nassafou,项目名称:blog,代码行数:11,代码来源:Article.php

示例12: 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();
     $this->context->addViolationAt($subPath, $message, $parameters, $value);
     $this->errors[] = array($message, $parameters, $value);
     return $this;
 }
开发者ID:ruslan-polutsygan,项目名称:SonataCoreBundle,代码行数:19,代码来源:ErrorElement.php

示例13: checkStock

 public function checkStock($value, ExecutionContextInterface $context)
 {
     $data = $context->getRoot()->getData();
     if (null === $data["product_sale_elements_id"]) {
         $context->addViolationAt("quantity", Translator::getInstance()->trans("Invalid product_sale_elements"));
     } else {
         $productSaleElements = ProductSaleElementsQuery::create()->filterById($data["product_sale_elements_id"])->filterByProductId($data["product"])->findOne();
         $product = $productSaleElements->getProduct();
         if ($productSaleElements->getQuantity() < $value && $product->getVirtual() === 0 && ConfigQuery::checkAvailableStock()) {
             $context->addViolation(Translator::getInstance()->trans("quantity value is not valid"));
         }
     }
 }
开发者ID:badelas,项目名称:thelia,代码行数:13,代码来源:CartAdd.php

示例14: 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

示例15: validateMethod

 public function validateMethod(ExecutionContextInterface $context)
 {
     if ($this->fakerConfig && !in_array($this->getMethod(), array_keys($this->fakerConfig->getMethods()))) {
         $context->addViolationAt('method', 'This method \'{{ method }}\' is not available in Faker.', ['{{ method }}' => $this->getMethod()], null);
     }
 }
开发者ID:csanquer,项目名称:fakery-generator,代码行数:6,代码来源:Variable.php


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