forked from doctrine/mongodb-odm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFriendUser.php
38 lines (30 loc) · 859 Bytes
/
FriendUser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/** @ODM\Document */
class FriendUser
{
/** @ODM\Id */
public $id;
/** @ODM\String */
public $name;
/**
* @ODM\ReferenceMany(targetDocument="FriendUser", mappedBy="myFriends", cascade={"all"})
*/
public $friendsWithMe;
/**
* @ODM\ReferenceMany(targetDocument="FriendUser", inversedBy="friendsWithMe", cascade={"all"})
*/
public $myFriends;
public function __construct($name)
{
$this->name = $name;
$this->friendsWithMe = new \Doctrine\Common\Collections\ArrayCollection();
$this->myFriends = new \Doctrine\Common\Collections\ArrayCollection();
}
public function addFriend(FriendUser $user)
{
$user->friendsWithMe[] = $this;
$this->myFriends[] = $user;
}
}