如果我們不能做到這一點的註釋:
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/*
* Project
* @ORM\Entity(repositoryClass="ProjectRepository")
*/
class Project
{
use ORMBehaviors\Translatable\Translatable;
/*
* => @ Assert\Valid not working on $translations, since tranlastion already defined by ORMBehaviors trait
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
//$metadata->addConstraint(new Assert\Valid());
$metadata->addPropertyConstraint('translations', new Assert\Valid());
}
和你的問題是什麼,你不明白什麼? –
我的問題是:如何訪問驗證器類中的其他實體值。問題是我不知道在哪裏設置驗證,以便能夠訪問其他實體值 –