|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace AppBundle\Entity\Infrasctucture; |
|
4
|
|
|
|
|
5
|
|
|
use AppBundle\Entity\BandMember; |
|
6
|
|
|
use AppBundle\Entity\User; |
|
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
8
|
|
|
use Doctrine\Common\Collections\Collection; |
|
9
|
|
|
use JMS\Serializer\Annotation\Accessor; |
|
10
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
11
|
|
|
use JMS\Serializer\Annotation\Type as SerializerType; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @author Vehsamrak |
|
15
|
|
|
* @ORM\MappedSuperclass |
|
16
|
|
|
*/ |
|
17
|
|
|
abstract class Ambassador |
|
18
|
|
|
{ |
|
19
|
|
|
use CreatorLoginTrait; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @var string |
|
23
|
|
|
* @ORM\Id |
|
24
|
|
|
* @ORM\Column(name="name", type="string", length=255, unique=true) |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $name; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var \DateTime |
|
30
|
|
|
* @ORM\Column(name="registration_date", type="datetime") |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $registrationDate; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $description; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var BandMember[]|ArrayCollection |
|
42
|
|
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\BandMember", mappedBy="band", orphanRemoval=true) |
|
43
|
|
|
* @Accessor(getter="getMembers") |
|
44
|
|
|
* @SerializerType("array") |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $members; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @var User |
|
50
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="createdBands") |
|
51
|
|
|
* @ORM\JoinColumn(name="creator", referencedColumnName="login") |
|
52
|
|
|
* @Accessor(getter="getCreatorLogin") |
|
53
|
|
|
* @SerializerType("string") |
|
54
|
|
|
*/ |
|
55
|
|
|
protected $creator; |
|
56
|
|
|
|
|
57
|
4 |
|
public function __construct(string $name, User $creator, string $description = null) |
|
58
|
|
|
{ |
|
59
|
4 |
|
$this->registrationDate = new \DateTime(); |
|
60
|
4 |
|
$this->name = $name; |
|
61
|
4 |
|
$this->description = $description; |
|
62
|
4 |
|
$this->members = new ArrayCollection(); |
|
63
|
4 |
|
$this->creator = $creator; |
|
64
|
4 |
|
} |
|
65
|
|
|
|
|
66
|
2 |
|
public function getId(): string |
|
67
|
|
|
{ |
|
68
|
2 |
|
return $this->name; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return Collection|BandMember[] |
|
73
|
|
|
*/ |
|
74
|
11 |
|
public function getMembers(): Collection |
|
75
|
|
|
{ |
|
76
|
11 |
|
return $this->members; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
3 |
|
public function addMember(BandMember $bandMember) |
|
80
|
|
|
{ |
|
81
|
3 |
|
$this->members->add($bandMember); |
|
82
|
3 |
|
} |
|
83
|
|
|
|
|
84
|
1 |
|
public function removeMember(BandMember $bandMember) |
|
85
|
|
|
{ |
|
86
|
1 |
|
$this->members->removeElement($bandMember); |
|
87
|
1 |
|
} |
|
88
|
|
|
|
|
89
|
1 |
|
public function setName(string $name) |
|
90
|
|
|
{ |
|
91
|
1 |
|
$this->name = $name; |
|
92
|
1 |
|
} |
|
93
|
|
|
|
|
94
|
1 |
|
public function setDescription(string $description) |
|
95
|
|
|
{ |
|
96
|
1 |
|
$this->description = $description; |
|
97
|
1 |
|
} |
|
98
|
|
|
|
|
99
|
7 |
|
public function getCreator(): User |
|
100
|
|
|
{ |
|
101
|
7 |
|
return $this->creator; |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|