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


PHP ExecutionContext::addViolationAtPath方法代码示例

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


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

示例1: isVoteValid

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

示例2: testAddViolationAtPathUsesPassedNullValue

 public function testAddViolationAtPathUsesPassedNullValue()
 {
     $this->translator->expects($this->once())->method('trans')->with('Error', array('foo' => 'bar'))->will($this->returnValue('Translated error'));
     $this->translator->expects($this->once())->method('transChoice')->with('Choice error', 3, array('foo' => 'bar'))->will($this->returnValue('Translated choice error'));
     // passed null value should override preconfigured value "invalid"
     set_error_handler(array($this, "deprecationErrorHandler"));
     $this->context->addViolationAtPath('bar.baz', 'Error', array('foo' => 'bar'), null);
     $this->context->addViolationAtPath('bar.baz', 'Choice error', array('foo' => 'bar'), null, 3);
     restore_error_handler();
     $this->assertEquals(new ConstraintViolationList(array(new ConstraintViolation('Translated error', 'Error', array('foo' => 'bar'), 'Root', 'bar.baz', null), new ConstraintViolation('Translated choice error', 'Choice error', array('foo' => 'bar'), 'Root', 'bar.baz', null, 3))), $this->context->getViolations());
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:11,代码来源:ExecutionContextTest.php

示例3: _validateDefaultCosId

 public function _validateDefaultCosId(ExecutionContext $context)
 {
     if (!is_null($this->getDefaultCosId()) && '' == trim($this->getDefaultCosId())) {
         $context->addViolationAtPath('defaultCosId', 'defaultCosId must be null or a valid Cos ID', array(), $this->getDefaultCosId());
     }
 }
开发者ID:jlaso,项目名称:zimbra-soap-api-bundle,代码行数:6,代码来源:Domain.php

示例4: isBilleePaymentMethodValid

 public function isBilleePaymentMethodValid(ExecutionContext $context)
 {
     // If user is not paying in full, then check cc/ach details
     if (!$this->getPayInFull()) {
         if ($this->getPaymentMethod()->getPaymentType() == 'CREDIT CARD') {
             if (!$this->getCcNum()) {
                 $context->addViolationAtPath('cc_num', 'Please add cc details');
             } else {
                 if (!$this->getCvvNumber()) {
                     $context->addViolationAtPath('cvv_number', 'Please add cvv numbers');
                 } else {
                     if (!$this->getCcExpirationDate()) {
                         $context->addViolationAtPath('cc_expiration_date', 'Please add cc exp date');
                     } else {
                         $today = new \DateTime();
                         if ($this->getCcExpirationDate() < $today) {
                             $context->addViolationAtPath('cc_expiration_date', 'Cc exp date must be in the future');
                         } else {
                             // now grab a pre-auth for the first payment
                             $pp = $this->getPaymentPlanCustomizedPayments();
                             $paymentObj = json_decode(stripslashes($pp['paymentsData']));
                             $payments = $paymentObj->payments;
                             $firstPayment = array_pop($payments);
                             $this->paymentGateway->setCardHoldersName((string) $this->getBilleeContact());
                             $this->paymentGateway->setCreditCardType($this->getPaymentMethod()->getName());
                             $this->paymentGateway->setCreditCardNumber($this->getCcNum());
                             $this->paymentGateway->setCreditCardExpiration($this->getCcExpirationDate());
                             $this->paymentGateway->setCreditCardVerification($this->getCvvNumber());
                             $this->paymentGateway->setCreditCardZipcode($this->getBilleeContact()->getPostalCode());
                             // $this->paymentGateway->setReferenceNumber(222);
                             try {
                                 $result = $this->paymentGateway->preAuth($firstPayment);
                                 $obj = json_decode($result);
                                 if (!$obj->transaction_error) {
                                     $this->setTransArmorToken($obj->transarmor_token);
                                 }
                             } catch (\Exception $e) {
                                 $context->addViolationAtPath('cc_num', $e->getMessage());
                             }
                             // ld($result);
                             // $obj = json_decode($result);
                             // $obj->transarmor_token;
                             // $obj->transaction_tag;
                             // $obj->retrieval_ref_no;
                             // $context->addViolationAtPath('cc_num', 'Bad cc num');
                         }
                     }
                 }
             }
         } else {
             if (!$this->getAccountNumber()) {
                 $context->addViolationAtPath('account_number', 'Please add account number');
             }
             if (!$this->getRoutingNumber()) {
                 $context->addViolationAtPath('routing_number', 'Please add routing number');
             }
         }
     }
 }
开发者ID:sgh1986915,项目名称:symfony-tsk,代码行数:59,代码来源:StudentRegistration.php


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