如果我们不能在注释中做到这一点:
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());
}