2014-02-21 10:30:41 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\Models\Tweet;
|
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Entity
|
|
|
|
* @Table(name="tweet_user")
|
|
|
|
*/
|
|
|
|
class User
|
|
|
|
{
|
2015-01-24 11:54:03 +01:00
|
|
|
const CLASSNAME = __CLASS__;
|
|
|
|
|
2014-02-21 10:30:41 +01:00
|
|
|
/**
|
|
|
|
* @Id
|
|
|
|
* @GeneratedValue
|
|
|
|
* @Column(type="integer")
|
|
|
|
*/
|
|
|
|
public $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Column(type="string")
|
|
|
|
*/
|
|
|
|
public $name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="Tweet", mappedBy="author", cascade={"persist"}, fetch="EXTRA_LAZY")
|
|
|
|
*/
|
|
|
|
public $tweets;
|
|
|
|
|
2015-01-27 07:42:48 +01:00
|
|
|
/**
|
|
|
|
* @OneToMany(targetEntity="UserList", mappedBy="owner", fetch="EXTRA_LAZY", orphanRemoval=true)
|
|
|
|
*/
|
|
|
|
public $userLists;
|
|
|
|
|
2014-02-21 10:30:41 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
2015-01-27 07:42:48 +01:00
|
|
|
$this->tweets = new ArrayCollection();
|
|
|
|
$this->userLists = new ArrayCollection();
|
2014-02-21 10:30:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function addTweet(Tweet $tweet)
|
|
|
|
{
|
|
|
|
$tweet->setAuthor($this);
|
|
|
|
$this->tweets->add($tweet);
|
|
|
|
}
|
2015-01-27 07:42:48 +01:00
|
|
|
|
|
|
|
public function addUserList(UserList $userList)
|
|
|
|
{
|
|
|
|
$userList->owner = $this;
|
|
|
|
$this->userLists->add($userList);
|
|
|
|
}
|
2014-02-21 10:30:41 +01:00
|
|
|
}
|