Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Models / CustomType / CustomTypeParent.php
1 <?php
2
3 namespace Doctrine\Tests\Models\CustomType;
4
5 /**
6  * @Entity
7  * @Table(name="customtype_parents")
8  */
9 class CustomTypeParent
10 {
11     /**
12      * @Id @Column(type="integer")
13      * @GeneratedValue(strategy="AUTO")
14      */
15     public $id;
16
17     /**
18      * @Column(type="negative_to_positive", nullable=true)
19      */
20     public $customInteger;
21
22     /**
23      * @OneToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeChild", cascade={"persist", "remove"})
24      */
25     public $child;
26
27     /**
28      * @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", mappedBy="myFriends")
29      */
30     private $friendsWithMe;
31
32     /**
33      * @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", inversedBy="friendsWithMe")
34      * @JoinTable(
35      *     name="customtype_parent_friends",
36      *     joinColumns={@JoinColumn(name="customtypeparent_id", referencedColumnName="id")},
37      *     inverseJoinColumns={@JoinColumn(name="friend_customtypeparent_id", referencedColumnName="id")}
38      * )
39      */
40     private $myFriends;
41
42     public function __construct()
43     {
44         $this->friendsWithMe = new \Doctrine\Common\Collections\ArrayCollection();
45         $this->myFriends = new \Doctrine\Common\Collections\ArrayCollection();
46     }
47
48     public function addMyFriend(CustomTypeParent $friend)
49     {
50         $this->getMyFriends()->add($friend);
51         $friend->addFriendWithMe($this);
52     }
53
54     public function getMyFriends()
55     {
56         return $this->myFriends;
57     }
58
59     public function addFriendWithMe(CustomTypeParent $friend)
60     {
61         $this->getFriendsWithMe()->add($friend);
62     }
63
64     public function getFriendsWithMe()
65     {
66         return $this->friendsWithMe;
67     }
68 }