1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Application\Model; |
6
|
|
|
|
7
|
|
|
use Application\Traits\HasDate; |
8
|
|
|
use Application\Traits\HasName; |
9
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
10
|
|
|
use Doctrine\Common\Collections\Collection; |
11
|
|
|
use Doctrine\ORM\Mapping as ORM; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* A news |
15
|
|
|
* |
16
|
|
|
* @ORM\Entity(repositoryClass="Application\Repository\EventRepository") |
17
|
|
|
*/ |
18
|
|
|
class Event extends AbstractModel |
19
|
|
|
{ |
20
|
|
|
private const IMAGE_PATH = 'htdocs/news/'; |
21
|
|
|
|
22
|
|
|
use HasName; |
23
|
|
|
use HasDate; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var Collection |
27
|
|
|
* @ORM\OneToMany(targetEntity="Comment", mappedBy="event") |
28
|
|
|
*/ |
29
|
|
|
private $comments; |
30
|
|
|
|
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
$this->comments = new ArrayCollection(); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
* @ORM\Column(type="string", length=191) |
39
|
|
|
*/ |
40
|
|
|
private $place; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Set place |
44
|
|
|
* |
45
|
|
|
* @param string $place |
46
|
|
|
*/ |
47
|
|
|
public function setPlace($place): void |
48
|
|
|
{ |
49
|
|
|
$this->place = $place; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get place |
54
|
|
|
* |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
|
|
public function getPlace(): string |
58
|
|
|
{ |
59
|
|
|
return (string) $this->place; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var string |
64
|
|
|
* @ORM\Column(type="string", length=191) |
65
|
|
|
*/ |
66
|
|
|
private $type; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Set type |
70
|
|
|
* |
71
|
|
|
* @param string $type |
72
|
|
|
*/ |
73
|
|
|
public function setType($type): void |
74
|
|
|
{ |
75
|
|
|
$this->type = $type; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Get type |
80
|
|
|
* |
81
|
|
|
* @return string |
82
|
|
|
*/ |
83
|
|
|
public function getType(): string |
84
|
|
|
{ |
85
|
|
|
return (string) $this->type; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Get comments sent to the event |
90
|
|
|
* |
91
|
|
|
* @return Collection |
92
|
|
|
*/ |
93
|
|
|
public function getComments(): Collection |
94
|
|
|
{ |
95
|
|
|
return $this->comments; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Notify the event that it has a new comment |
100
|
|
|
* This should only be called by Comment::setEvent() |
101
|
|
|
* |
102
|
|
|
* @param Comment $comment |
103
|
|
|
*/ |
104
|
|
|
public function commentAdded(Comment $comment): void |
105
|
|
|
{ |
106
|
|
|
$this->comments->add($comment); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Notify the event that a comment was removed |
111
|
|
|
* This should only be called by Comment::setEvent() |
112
|
|
|
* |
113
|
|
|
* @param Comment $comment |
114
|
|
|
*/ |
115
|
|
|
public function commentRemoved(Comment $comment): void |
116
|
|
|
{ |
117
|
|
|
$this->comments->removeElement($comment); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|