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


PHP ExecutionContextInterface::markConstraintAsValidated方法代码示例

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


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

示例1: validateConstraints

 /**
  * Validates a node's value against all constraints in the given group.
  *
  * @param mixed $value
  *   The validated value.
  * @param string $cache_key
  *   The cache key used internally to ensure we don't validate the same
  *   constraint twice.
  * @param \Symfony\Component\Validator\Constraint[] $constraints
  *   The constraints which should be ensured for the given value.
  */
 protected function validateConstraints($value, $cache_key, $constraints)
 {
     foreach ($constraints as $constraint) {
         // Prevent duplicate validation of constraints, in the case
         // that constraints belong to multiple validated groups
         if (isset($cache_key)) {
             $constraint_hash = spl_object_hash($constraint);
             if ($this->context->isConstraintValidated($cache_key, $constraint_hash)) {
                 continue;
             }
             $this->context->markConstraintAsValidated($cache_key, $constraint_hash);
         }
         $this->context->setConstraint($constraint);
         $validator = $this->constraintValidatorFactory->getInstance($constraint);
         $validator->initialize($this->context);
         $validator->validate($value, $constraint);
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:RecursiveContextualValidator.php

示例2: validateInGroup

 /**
  * Validates a node's value against all constraints in the given group.
  *
  * @param mixed                     $value      The validated value
  * @param string                    $cacheKey   The key for caching the
  *                                              validated value
  * @param MetadataInterface         $metadata   The metadata of the value
  * @param string                    $group      The group to validate
  * @param ExecutionContextInterface $context    The execution context
  */
 private function validateInGroup($value, $cacheKey, MetadataInterface $metadata, $group, ExecutionContextInterface $context)
 {
     $context->setGroup($group);
     foreach ($metadata->findConstraints($group) as $constraint) {
         // Prevent duplicate validation of constraints, in the case
         // that constraints belong to multiple validated groups
         if (null !== $cacheKey) {
             $constraintHash = spl_object_hash($constraint);
             if ($context->isConstraintValidated($cacheKey, $constraintHash)) {
                 continue;
             }
             $context->markConstraintAsValidated($cacheKey, $constraintHash);
         }
         $context->setConstraint($constraint);
         $validator = $this->validatorFactory->getInstance($constraint);
         $validator->initialize($context);
         $validator->validate($value, $constraint);
     }
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:29,代码来源:RecursiveContextualValidator.php


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