entity User.php
/** * @var \Doctrine\Common\Collections\ArrayCollection * * @ORM\ManyToMany(targetEntity="Acme\CommentBundle\Entity\Following") * @ORM\JoinTable(name="following", * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="follower_id", referencedColumnName="id")} * ) */ protected $followers;
Following.php
protected $id; protected $user_id; protected $follower_id;
Gdy próbuje tak:
$em = $this->getDoctrine()->getManager(); $user = $this->get('security.context')->getToken()->getUser(); $user->getFollowers()->add($follower); $em->flush();
otrzymuje błąd Found entity of type Acme\UserBundle\Entity\User on association Acme\UserBundle\Entity\User#followers, but expecting Acme\CommentBundle\Entity\Following
Dlaczego?
#prolem rozwazany