本文整理汇总了PHP中Symfony\Component\Validator\Constraint::getBundleOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Constraint::getBundleOption方法的具体用法?PHP Constraint::getBundleOption怎么用?PHP Constraint::getBundleOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\Constraint
的用法示例。
在下文中一共展示了Constraint::getBundleOption方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* {@inheritdoc}
*/
public function validate($entity, Constraint $constraint)
{
if (!isset($entity)) {
return;
}
if (!in_array($entity->bundle(), $constraint->getBundleOption())) {
$this->context->addViolation($constraint->message, array('%bundle' => implode(', ', $constraint->getBundleOption())));
}
}
示例2: validate
/**
* {@inheritdoc}
*/
public function validate($entity_adapter, Constraint $constraint)
{
if (!isset($entity_adapter)) {
return;
}
// @todo The $entity_adapter parameter passed to this function should always
// be a typed data object, but due to a bug, the unwrapped entity is
// passed for the computed entity property of entity reference fields.
// Remove this after fixing that in https://www.drupal.org/node/2346373.
if (!$entity_adapter instanceof TypedDataInterface) {
$entity = $entity_adapter;
} else {
$entity = $entity_adapter->getValue();
}
if (!in_array($entity->bundle(), $constraint->getBundleOption())) {
$this->context->addViolation($constraint->message, array('%bundle' => implode(', ', $constraint->getBundleOption())));
}
}