0
我正在使用Gedmo扩展以及Symfony 3.2和Doctrine 2.5.6,并且遇到了问题。我不能让Gedmo \ Blameable和UniqueEntity约束一起工作。事实上,在验证时间,责备领域仍然是空的。有没有办法让它工作或可能的解决方法?在Gedmo Blameable字段上使用UniqueEntity
这里是我的实体
/**
* @UniqueEntity(
* fields={"author", "question"},
* errorPath="question",
* message="This author already has an answer for that Question"
*)
* @ORM\Entity
*/
class TextAnswer
{
/**
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
* @Gedmo\Blameable(on="create")
*/
private $author;
/**
* @Assert\NotNull()
* @ORM\ManyToOne(targetEntity="Question", inversedBy="textAnswers")
* @ORM\JoinColumn(name="question_id", referencedColumnName="id")
*/
private $question;
}
感谢
编辑:解
而不是手动设置的用户(删除Gedmo \ Blameable利益),我创建了自己的实体验证。 我将它作为参数赋予它的学说和标记存储,以便它可以对db进行查询,以便与当前连接的用户验证我的标准(稍后将由Gedmo \ Blameable使用)。
原以为这是外语_UniqueEntity Gedmo Blameable_ – AbraCadaver