本文整理汇总了PHP中Symfony\Component\Validator\Context\ExecutionContextInterface::setGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContextInterface::setGroup方法的具体用法?PHP ExecutionContextInterface::setGroup怎么用?PHP ExecutionContextInterface::setGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\Context\ExecutionContextInterface
的用法示例。
在下文中一共展示了ExecutionContextInterface::setGroup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setGroup
protected function setGroup($group)
{
$this->group = $group;
switch ($this->getApiVersion()) {
case Validation::API_VERSION_2_4:
$this->context = $this->createContext();
$this->validator->initialize($this->context);
break;
case Validation::API_VERSION_2_5:
case Validation::API_VERSION_2_5_BC:
$this->context->setGroup($group);
break;
}
}
示例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);
}
}
示例3: setGroup
protected function setGroup($group)
{
$this->group = $group;
$this->context->setGroup($group);
}