Total Complexity | 10 |
Total Lines | 70 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
14 | #[ORM\Entity(CommentRepository::class)] |
||
15 | class Comment extends AbstractModel |
||
16 | { |
||
17 | use HasRichTextDescription; |
||
18 | |||
19 | #[ORM\JoinColumn(onDelete: 'CASCADE')] |
||
20 | #[ORM\ManyToOne(targetEntity: Event::class, inversedBy: 'comments')] |
||
21 | private ?Event $event = null; |
||
22 | |||
23 | /** |
||
24 | * Set event. |
||
25 | */ |
||
26 | public function setEvent(?Event $event): void |
||
27 | { |
||
28 | if ($this->event) { |
||
29 | $this->event->commentRemoved($this); |
||
30 | } |
||
31 | |||
32 | $this->event = $event; |
||
33 | |||
34 | if ($this->event) { |
||
35 | $this->event->commentAdded($this); |
||
36 | } |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Get event. |
||
41 | */ |
||
42 | public function getEvent(): ?Event |
||
43 | { |
||
44 | return $this->event; |
||
45 | } |
||
46 | |||
47 | #[ORM\JoinColumn(onDelete: 'CASCADE')] |
||
48 | #[ORM\ManyToOne(targetEntity: News::class, inversedBy: 'comments')] |
||
49 | private ?News $news = null; |
||
50 | |||
51 | /** |
||
52 | * Set news. |
||
53 | */ |
||
54 | public function setNews(?News $news): void |
||
55 | { |
||
56 | if ($this->news) { |
||
57 | $this->news->commentRemoved($this); |
||
58 | } |
||
59 | |||
60 | $this->news = $news; |
||
61 | |||
62 | if ($this->news) { |
||
63 | $this->news->commentAdded($this); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Get news. |
||
69 | */ |
||
70 | public function getNews(): ?News |
||
71 | { |
||
72 | return $this->news; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Get owner name. |
||
77 | */ |
||
78 | public function getAuthorName(): string |
||
84 | }); |
||
85 | } |
||
86 | } |
||
87 |