Validation 我是否可以将用户验证程序作为一项服务来检查谁有权删除实体

Validation 我是否可以将用户验证程序作为一项服务来检查谁有权删除实体,validation,symfony,Validation,Symfony,如果我是对的,我可以使用验证器检查$comments是否由允许发布评论的用户创建 例如: 假设我有一个用户实体,它有一个comment_allow属性,该属性的值可以是“yes”或“no” 验证器 class commentvalidator extends ConstraintValidator if(comments->getAuthor()->getComment_allow() == no) { $this->context->addViolation($c

如果我是对的,我可以使用验证器检查$comments是否由允许发布评论的用户创建

例如: 假设我有一个用户实体,它有一个comment_allow属性,该属性的值可以是“yes”或“no”

验证器

class commentvalidator extends ConstraintValidator
if(comments->getAuthor()->getComment_allow() == no)
{
   $this->context->addViolation($constaint->message)
}

但是我可以做一些类似于删除评论的事情吗,并通过验证器检查评论是否仅由作者删除。到目前为止,我不知道将@commentdelete validator附加到何处,因为它不是一个必须进行验证的创建,而是在删除注释时进行的验证

class commentvalidator extends ConstraintValidator
if(comments->getAuthor()->getComment_allow() == no)
{
   $this->context->addViolation($constaint->message)
}