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 FormattedRegistrationDateTrait; |
20
|
|
|
use CreatorLoginTrait; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
* @ORM\Id |
25
|
|
|
* @ORM\Column(name="name", type="string", length=255) |
26
|
|
|
*/ |
27
|
|
|
protected $name; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var \DateTime |
31
|
|
|
* @ORM\Column(name="registration_date", type="datetime") |
32
|
|
|
* @Accessor(getter="getRegistrationDate") |
33
|
|
|
* @SerializerType("string") |
34
|
|
|
*/ |
35
|
|
|
protected $registrationDate; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
* @ORM\Column(name="description", type="text", nullable=true) |
40
|
|
|
*/ |
41
|
|
|
protected $description; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var BandMember[]|ArrayCollection |
45
|
|
|
* @ORM\OneToMany(targetEntity="AppBundle\Entity\BandMember", mappedBy="band", orphanRemoval=true) |
46
|
|
|
* @Accessor(getter="getMembers") |
47
|
|
|
* @SerializerType("array") |
48
|
|
|
*/ |
49
|
|
|
protected $members; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var User |
53
|
|
|
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\User", inversedBy="createdBands") |
54
|
|
|
* @ORM\JoinColumn(name="creator", referencedColumnName="login") |
55
|
|
|
* @Accessor(getter="getCreatorLogin") |
56
|
|
|
* @SerializerType("string") |
57
|
|
|
*/ |
58
|
|
|
protected $creator; |
59
|
|
|
|
60
|
2 |
|
public function __construct(string $name, User $creator, string $description = null) |
61
|
|
|
{ |
62
|
2 |
|
$this->registrationDate = new \DateTime(); |
63
|
2 |
|
$this->name = $name; |
64
|
2 |
|
$this->description = $description; |
65
|
2 |
|
$this->members = new ArrayCollection(); |
66
|
2 |
|
$this->creator = $creator; |
67
|
2 |
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return Collection|BandMember[] |
71
|
|
|
*/ |
72
|
8 |
|
public function getMembers(): Collection |
73
|
|
|
{ |
74
|
8 |
|
return $this->members; |
75
|
|
|
} |
76
|
|
|
|
77
|
3 |
|
public function addMember(BandMember $bandMember) |
78
|
|
|
{ |
79
|
3 |
|
$this->members->add($bandMember); |
80
|
3 |
|
} |
81
|
|
|
|
82
|
1 |
|
public function removeMember(BandMember $bandMember) |
83
|
|
|
{ |
84
|
1 |
|
$this->members->removeElement($bandMember); |
85
|
1 |
|
} |
86
|
|
|
|
87
|
1 |
|
public function setName(string $name) |
88
|
|
|
{ |
89
|
1 |
|
$this->name = $name; |
90
|
1 |
|
} |
91
|
|
|
|
92
|
1 |
|
public function setDescription(string $description) |
93
|
|
|
{ |
94
|
1 |
|
$this->description = $description; |
95
|
1 |
|
} |
96
|
|
|
} |
97
|
|
|
|