當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConstraintViolationList::__toString方法代碼示例

本文整理匯總了PHP中Symfony\Component\Validator\ConstraintViolationList::__toString方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConstraintViolationList::__toString方法的具體用法?PHP ConstraintViolationList::__toString怎麽用?PHP ConstraintViolationList::__toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Validator\ConstraintViolationList的用法示例。


在下文中一共展示了ConstraintViolationList::__toString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1:

 function it_throws_exception_on_validation_failure(MethodInterface $method, ValidatorInterface $validator, ConstraintViolationList $violations)
 {
     $attributes = ['field' => 'value'];
     $constraints = ['constraints'];
     $method->getValidationConstraints()->shouldBeCalled()->willReturn($constraints);
     $method->getAttributes()->shouldBeCalled()->willReturn($attributes);
     $violations->count()->willReturn(1);
     $violations->__toString()->willReturn('');
     $validator->validate($attributes, $constraints)->willReturn($violations);
     $this->shouldThrow('Cardinity\\Exception\\InvalidAttributeValue')->duringValidate($method);
 }
開發者ID:web3d,項目名稱:mincart,代碼行數:11,代碼來源:ValidatorSpec.php

示例2: isValidRedirectUrl

 /**
  * Checks whether the given value is a valid URL that may probably be safely used as a redirect url.
  *
  * @param string $value URL to validate
  *
  * @return boolean true if the url is correct
  */
 protected function isValidRedirectUrl($value)
 {
     $validator = Validation::createValidator();
     $constraints = array(new Constraints\Type(array('type' => 'string')), new Constraints\Length(array('min' => $this->getParameter('min_length', 10), 'max' => $this->getParameter('max_length', 1000))), new Constraints\Url(array('protocols' => $this->getParameter('allowed_protocols', array('http', 'https')))));
     if ($this->getParameter('check_base_href', true)) {
         $constraints[] = new Constraints\Callback(array('methods' => array(array($this, 'hasCorrectBaseHref'))));
     }
     $violations = new ConstraintViolationList();
     foreach ($constraints as $constraint) {
         $violations->addAll($validator->validateValue($value, $constraint));
     }
     if ($violations->count() === 0) {
         return true;
     } else {
         $this->getContext()->getLoggerManager()->logTo('default', \AgaviLogger::WARNING, __METHOD__, $violations->__toString());
         return false;
     }
 }
開發者ID:honeybee,項目名稱:honeybee-agavi-cmf-vendor,代碼行數:25,代碼來源:RedirectValidator.php

示例3: let

 function let(ConstraintViolationList $violations)
 {
     $violations->__toString()->willReturn($this->violation);
     $this->beConstructedWith('Message', $violations);
 }
開發者ID:web3d,項目名稱:mincart,代碼行數:5,代碼來源:InvalidAttributeValueSpec.php


注:本文中的Symfony\Component\Validator\ConstraintViolationList::__toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。