-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
CustomTypeParent.php
84 lines (71 loc) · 2.08 KB
/
CustomTypeParent.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
declare(strict_types=1);
namespace Doctrine\Tests\Models\CustomType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @Entity
* @Table(name="customtype_parents")
*/
class CustomTypeParent
{
/**
* @var int
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
public $id;
/**
* @var int
* @Column(type="negative_to_positive", nullable=true)
*/
public $customInteger;
/**
* @var CustomTypeChild
* @OneToOne(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeChild", cascade={"persist", "remove"})
*/
public $child;
/**
* @psalm-var Collection<int, CustomTypeParent>
* @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", mappedBy="myFriends")
*/
private $friendsWithMe;
/**
* @psalm-var Collection<int, CustomTypeParent>
* @ManyToMany(targetEntity="Doctrine\Tests\Models\CustomType\CustomTypeParent", inversedBy="friendsWithMe")
* @JoinTable(
* name="customtype_parent_friends",
* joinColumns={@JoinColumn(name="customtypeparent_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="friend_customtypeparent_id", referencedColumnName="id")}
* )
*/
private $myFriends;
public function __construct()
{
$this->friendsWithMe = new ArrayCollection();
$this->myFriends = new ArrayCollection();
}
public function addMyFriend(CustomTypeParent $friend): void
{
$this->getMyFriends()->add($friend);
$friend->addFriendWithMe($this);
}
/**
* @psalm-return Collection<int, CustomTypeParent>
*/
public function getMyFriends(): Collection
{
return $this->myFriends;
}
public function addFriendWithMe(CustomTypeParent $friend): void
{
$this->getFriendsWithMe()->add($friend);
}
/**
* @psalm-return Collection<int, CustomTypeParent>
*/
public function getFriendsWithMe()
{
return $this->friendsWithMe;
}
}