I want to implement this type of relationship:
Class SimpleUser must have a "languages" class property which should contain list of all SimpleLanguage-s that are binded to the current user in the UserLanguages table.
Please look at the classes:
public class SimpleUser {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=50)
*/
private $name;
// what do I type here? I want to have SimpleLanguage[] here
private $languages;
}
public class SimpleLanguage {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=50)
*/
private $name;
}
public class UserLanguages {
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var integer
* @ORM\Column(name="user_id", type="integer")
*/
private $userId;
/**
* @var integer
* @ORM\Column(name="language_id", type="integer")
*/
private $languageId;
/**
* @var SimpleUser
*
* @ManyToOne(targetEntity="SimpleUser")
* @JoinColumn(name="userId", referencedColumnName="id")
*/
private $user;
/**
* @var SimpleLanguage
*
* @ManyToOne(targetEntity="SimpleLanguage")
* @JoinColumn(name="languageId", referencedColumnName="id")
*/
private $language;
}