本文整理汇总了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);
}
}
示例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());
}
示例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());
}
}
示例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');
}
}
}
}