Mam problem problem z przesłaniem danych.

entity User.php
  1. /**
  2.   * @var \Doctrine\Common\Collections\ArrayCollection
  3.   *
  4.   * @ORM\ManyToMany(targetEntity="Acme\CommentBundle\Entity\Following")
  5.   * @ORM\JoinTable(name="following",
  6.   * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
  7.   * inverseJoinColumns={@ORM\JoinColumn(name="follower_id", referencedColumnName="id")}
  8.   * )
  9.   */
  10. protected $followers;


Following.php
  1. protected $id;
  2.  
  3. protected $user_id;
  4.  
  5. protected $follower_id;


Gdy próbuje tak:
  1. $em = $this->getDoctrine()->getManager();
  2. $follower = $em->getRepository('AcmeUserBundle:User')->findOneBy(array('id' = 1));
  3. $user = $this->get('security.context')->getToken()->getUser();
  4. $user->getFollowers()->add($follower);
  5. $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