I would like to make a relationship ManyToMany with two entity:
- User (used with FOSUserBundle)
- Categorie
For the moment, I'm doing this in "MyNamespace/Userbundle/Entity/User.php" :
/**
* @ORM\ManyToMany(targetEntity="\MyNamespace\WebsiteBundle\Entity\Categorie", inversedBy="users")
* @ORM\JoinTable(name="user_has_categories")
*/
private $categories;
public function __construct()
{
parent::__construct();
$this->categories = new \Doctrine\Common\Collections\ArrayCollection();
}
And this in "MyNameSpace/WebsiteBundle/Entity/Categorie.php" :
/**
* @ORM\ManyToMany(targetEntity="\MyNameSpace\UserBundle\Entity\User", mappedBy="categories")
*/
private $users;
public function __construct()
{
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}
When I run the doctrine command for create the table with the reationship, everything is OK.
But when I do a var_dump($this->getUser());
in my default controller (for exemple), I have an infinite loop that crashes my browser.
This effect no longer appears when I delete the relationship in my User entity ...
That would have an idea where this problem may be?
I turn with php 5.4.9 on ubuntu
Thank's :)