1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Project\Domain\Article\Entity; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use App\Project\Domain\User\Entity\User; |
7
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
8
|
|
|
use Gedmo\Sluggable\Util as Sluggable; |
9
|
|
|
|
10
|
|
|
class Article |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @var integer |
15
|
|
|
*/ |
16
|
|
|
protected $id; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $body; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var string |
25
|
|
|
*/ |
26
|
|
|
protected $title; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var User |
30
|
|
|
*/ |
31
|
|
|
protected $author; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var Tag|ArrayCollection |
35
|
|
|
*/ |
36
|
|
|
protected $tags; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var ArrayCollection |
40
|
|
|
*/ |
41
|
|
|
protected $images; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var ArrayCollection|User |
45
|
|
|
*/ |
46
|
|
|
protected $contributors; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return int |
50
|
|
|
*/ |
51
|
|
|
public function getId(): int |
52
|
|
|
{ |
53
|
|
|
return $this->id; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getBody(): string |
60
|
|
|
{ |
61
|
|
|
return $this->body; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $body |
66
|
|
|
*/ |
67
|
|
|
public function setBody(string $body) |
68
|
|
|
{ |
69
|
|
|
$this->body = $body; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getTitle(): string |
76
|
|
|
{ |
77
|
|
|
return $this->title; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $title |
82
|
|
|
*/ |
83
|
|
|
public function setTitle(string $title) |
84
|
|
|
{ |
85
|
|
|
$this->title = $title; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return User |
90
|
|
|
*/ |
91
|
|
|
public function getAuthor(): User |
92
|
|
|
{ |
93
|
|
|
return $this->author; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param User $author |
98
|
|
|
*/ |
99
|
|
|
public function setAuthor(User $author) |
100
|
|
|
{ |
101
|
|
|
$this->author = $author; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return Tag|ArrayCollection |
106
|
|
|
*/ |
107
|
|
|
public function getTags() |
108
|
|
|
{ |
109
|
|
|
return $this->tags; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param Tag|ArrayCollection $tags |
114
|
|
|
*/ |
115
|
|
|
public function setTags($tags) |
116
|
|
|
{ |
117
|
|
|
$this->tags = $tags; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param Tag $tag |
122
|
|
|
*/ |
123
|
|
|
public function addTag(Tag $tag) |
124
|
|
|
{ |
125
|
|
|
if (!$this->tags->contains($tag)) { |
|
|
|
|
126
|
|
|
$this->tags->add($tag); |
|
|
|
|
127
|
|
|
} |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
public function addTagFromName($name) |
131
|
|
|
{ |
132
|
|
|
$tag = new Tag(); |
133
|
|
|
$slug = Sluggable\Urlizer::urlize($name, '-'); |
134
|
|
|
$tag->setTitle($name); |
135
|
|
|
$tag->setSlug($slug); |
136
|
|
|
|
137
|
|
|
$this->tags->add($tag); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return ArrayCollection |
142
|
|
|
*/ |
143
|
|
|
public function getImages(): ArrayCollection |
144
|
|
|
{ |
145
|
|
|
return $this->images; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param ArrayCollection $images |
150
|
|
|
*/ |
151
|
|
|
public function setImages(ArrayCollection $images) |
152
|
|
|
{ |
153
|
|
|
$this->images = $images; |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @return User|ArrayCollection |
158
|
|
|
*/ |
159
|
|
|
public function getContributors() |
160
|
|
|
{ |
161
|
|
|
return $this->contributors; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param User|ArrayCollection $contributors |
166
|
|
|
*/ |
167
|
|
|
public function setContributors($contributors) |
168
|
|
|
{ |
169
|
|
|
$this->contributors = $contributors; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param User $contributor |
174
|
|
|
*/ |
175
|
|
|
public function addContributor(User $contributor) |
176
|
|
|
{ |
177
|
|
|
if (!$this->contributors->contains($contributor)) { |
|
|
|
|
178
|
|
|
$this->contributors->add($contributor); |
|
|
|
|
179
|
|
|
} |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
|
183
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.