I have class with many variables. Few of them are File types
class Proposal {
/**
* @ORM\ManyToOne(targetEntity="File")
* @ORM\JoinColumn(name="clientCommFile_id", referencedColumnName="id") */
private $clientCommFile;
/**
* @ORM\ManyToOne(targetEntity="File")
* @ORM\JoinColumn(name="contractFile_id", referencedColumnName="id")
*/
private $contractFile;
/**
* @ORM\ManyToOne(targetEntity="File")
* @ORM\JoinColumn(name="proposalFile_id", referencedColumnName="id")
*/
private $proposalFile;
I need do create some validation rule to validate which will inspect ids of files. The ids must be different because it referres to files in database.
Is some way, how to do this?
So you want clientCommFile, contractFile and proposalFile to be different? Assuming one can just compare objects, here is how it goes:
Of course you must implement the equals method on your objects.
If it gets more complicated or you need Database access, have a look at custom validators