사용자 정의 유효성 검사기에서 유효성이 검사 된 엔티티 클래스를 가져올 수 있는지 알고 싶습니다. 아니 당신은 할 수 없습니다사용자 정의 유효성 검사기에서 엔티티 클래스 가져 오기
use Symfony\Component\Validator\Constraint;
class UniqueKey extends Constraint {
public $message = 'The string "%string%" is not good';
public function validatedBy() {
return get_class($this).'Validator';
}
}
class UniqueKeyValidator extends ConstraintValidator {
public function validate($value, Constraint $constraint) {
// I would like to get the class of the entity validated. Can I?
}
}
[* Class Constraint Validator *] (https://symfony.com/doc/current/validation/custom_constraint.html#class-constraint-validator)로 만들 수 있습니까? – Yoshi