public function getTimeline(User $user)
 {
     return $this->_em->createQuery('
             SELECT
                 tweet
             FROM
                 TwitterDomainBundle:Tweet tweet
             JOIN tweet.user author
             WHERE author.id IN (
                 SELECT
                     follower.id
                 FROM
                     TwitterDomainBundle:User me
                 JOIN me.following follower
                 WHERE
                     me.id = :id
             )
             ORDER BY
                 tweet.id DESC')->setParameter('id', $user->getId())->getResult();
 }
 public function getUser()
 {
     $user = new User();
     $user->setUsername($this->username);
     $user->setEmail($this->email);
     $user->setPassword($this->password);
     $user->setEnabled(true);
     return $user;
 }
 /**
  * Get users following by user
  *
  * **Response Format**
  *
  *      {
  *          "following": [
  *              {
  *                  "username": "******",
  *              }
  *          ]
  *      }
  *
  * @ApiDoc(
  *     section="User"
  * )
  */
 public function getFollowingAction(User $user)
 {
     return array('following' => $user->getFollowing());
 }
 public function setUser(User $user)
 {
     $this->user = $user;
     $this->user->addTweet($this);
 }