This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Victoire\Bundle\BlogBundle\Entity; |
||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; |
||
6 | use Gedmo\Mapping\Annotation as Gedmo; |
||
7 | use Gedmo\Timestampable\Traits\TimestampableEntity; |
||
8 | use Knp\DoctrineBehaviors\Model\Translatable\Translatable; |
||
9 | use Symfony\Component\PropertyAccess\PropertyAccess; |
||
10 | use Symfony\Component\Validator\Constraints as Assert; |
||
11 | use Victoire\Bundle\BusinessEntityBundle\Entity\BusinessEntityInterface; |
||
12 | use Victoire\Bundle\BusinessEntityBundle\Entity\Traits\BusinessEntityTrait; |
||
13 | use Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate; |
||
14 | use Victoire\Bundle\CoreBundle\Annotations as VIC; |
||
15 | use Victoire\Bundle\PageBundle\Entity\PageStatus; |
||
16 | |||
17 | /** |
||
18 | * @ORM\Entity(repositoryClass="Victoire\Bundle\BlogBundle\Repository\ArticleRepository")) |
||
19 | * @ORM\Table("vic_article") |
||
20 | * @VIC\BusinessEntity({"Date", "Force", "Redactor", "Listing", "BlogArticles", "Title", "CKEditor", "Text", "UnderlineTitle", "Cover", "Image", "Authorship", "ArticleList", "SliderNav", "Render"}) |
||
21 | * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false) |
||
22 | */ |
||
23 | class Article implements BusinessEntityInterface |
||
24 | { |
||
25 | use BusinessEntityTrait; |
||
26 | use TimestampableEntity; |
||
27 | use Translatable; |
||
28 | |||
29 | /** |
||
30 | * @VIC\BusinessProperty("businessParameter") |
||
31 | * @ORM\Column(name="id", type="integer") |
||
32 | * @ORM\Id |
||
33 | * @ORM\GeneratedValue(strategy="AUTO") |
||
34 | */ |
||
35 | private $id; |
||
36 | |||
37 | /** |
||
38 | * @deprecated |
||
39 | * Title is inherited from Page, just add the BusinessProperty annotation. |
||
40 | * |
||
41 | * @ORM\Column(name="name", type="string", length=255, nullable=true) |
||
42 | */ |
||
43 | private $name; |
||
0 ignored issues
–
show
|
|||
44 | |||
45 | /** |
||
46 | * @deprecated |
||
47 | * @ORM\Column(name="slug", type="string", length=255, nullable=true) |
||
48 | */ |
||
49 | private $slug; |
||
0 ignored issues
–
show
|
|||
50 | |||
51 | /** |
||
52 | * @deprecated |
||
53 | * Description is inherited from Page, just add the BusinessProperty annotation. |
||
54 | * |
||
55 | * @ORM\Column(name="description", type="text", nullable=true) |
||
56 | */ |
||
57 | private $description; |
||
0 ignored issues
–
show
|
|||
58 | |||
59 | /** |
||
60 | * @deprecated |
||
61 | * |
||
62 | * @var string |
||
63 | * |
||
64 | * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\MediaBundle\Entity\Media") |
||
65 | * @ORM\JoinColumn(name="image_id", referencedColumnName="id", onDelete="CASCADE") |
||
66 | * @VIC\BusinessProperty("imageable") |
||
67 | */ |
||
68 | private $image; |
||
0 ignored issues
–
show
|
|||
69 | |||
70 | /** |
||
71 | * @ORM\Column(name="status", type="string", nullable=false) |
||
72 | */ |
||
73 | protected $status; |
||
74 | |||
75 | /** |
||
76 | * Categories of the article. |
||
77 | * |
||
78 | * @ORM\ManyToOne(targetEntity="Category", inversedBy="articles") |
||
79 | * @ORM\JoinColumn(onDelete="SET NULL") |
||
80 | * @VIC\BusinessProperty({"textable", "seoable"}) |
||
81 | */ |
||
82 | private $category; |
||
83 | |||
84 | /** |
||
85 | * @var datetime |
||
86 | * |
||
87 | * @ORM\Column(name="publishedAt", type="datetime", nullable=true) |
||
88 | * @VIC\BusinessProperty({"dateable", "textable"}) |
||
89 | */ |
||
90 | private $publishedAt; |
||
91 | |||
92 | /** |
||
93 | * This relation is dynamically added by ArticleSubscriber |
||
94 | * The property is needed here. |
||
95 | * |
||
96 | * @VIC\BusinessProperty({"textable", "seoable"}) |
||
97 | */ |
||
98 | private $author; |
||
99 | |||
100 | /** |
||
101 | * Tags of the article. |
||
102 | * |
||
103 | * @ORM\ManyToMany(targetEntity="Tag", inversedBy="articles") |
||
104 | * @ORM\JoinTable(name="vic_article_tags") |
||
105 | * @Assert\Valid() |
||
106 | */ |
||
107 | private $tags; |
||
108 | |||
109 | /** |
||
110 | * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\BlogBundle\Entity\Blog", inversedBy="articles", cascade={"persist"}) |
||
111 | * @ORM\JoinColumn(name="blog_id", referencedColumnName="id", onDelete="CASCADE") |
||
112 | */ |
||
113 | private $blog; |
||
114 | |||
115 | /** |
||
116 | * @var BusinessTemplate |
||
117 | * @ORM\ManyToOne(targetEntity="ArticleTemplate") |
||
118 | * @ORM\JoinColumn(name="template_id", referencedColumnName="id", onDelete="SET NULL") |
||
119 | * @Assert\NotNull() |
||
120 | */ |
||
121 | private $template; |
||
122 | |||
123 | /** |
||
124 | * @VIC\BusinessProperty("textable") |
||
125 | */ |
||
126 | private $categoryTitle; |
||
127 | |||
128 | /** |
||
129 | * @VIC\BusinessProperty("textable") |
||
130 | */ |
||
131 | private $publishedAtString; |
||
0 ignored issues
–
show
|
|||
132 | |||
133 | /** |
||
134 | * @VIC\BusinessProperty({"textable", "imageable"}) |
||
135 | */ |
||
136 | private $authorAvatar; |
||
137 | |||
138 | /** |
||
139 | * @VIC\BusinessProperty("textable") |
||
140 | */ |
||
141 | private $authorFullName; |
||
142 | |||
143 | /** |
||
144 | * @ORM\Column(name="deletedAt", type="datetime", nullable=true) |
||
145 | */ |
||
146 | private $deletedAt; |
||
147 | |||
148 | /** |
||
149 | * @Gedmo\Locale |
||
150 | */ |
||
151 | protected $locale; |
||
152 | |||
153 | /** |
||
154 | * to string method. |
||
155 | * |
||
156 | * @return string |
||
157 | */ |
||
158 | public function __toString() |
||
159 | { |
||
160 | return $this->getName(); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * Constructor. |
||
165 | */ |
||
166 | public function __construct() |
||
167 | { |
||
168 | $this->status = PageStatus::DRAFT; |
||
169 | } |
||
170 | |||
171 | /** |
||
172 | * Get id. |
||
173 | * |
||
174 | * @return int |
||
175 | */ |
||
176 | public function getId() |
||
177 | { |
||
178 | return $this->id; |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * Set id. |
||
183 | * |
||
184 | * @param int $id |
||
185 | */ |
||
186 | public function setId($id) |
||
187 | { |
||
188 | $this->id = $id; |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * Get category. |
||
193 | * |
||
194 | * @return string |
||
195 | */ |
||
196 | public function getCategory() |
||
197 | { |
||
198 | return $this->category; |
||
199 | } |
||
200 | |||
201 | /** |
||
202 | * Set category. |
||
203 | * |
||
204 | * @param Category $category |
||
205 | * |
||
206 | * @return Article |
||
207 | */ |
||
208 | public function setCategory(Category $category) |
||
209 | { |
||
210 | $this->category = $category; |
||
211 | } |
||
212 | |||
213 | /** |
||
214 | * Get the published at property. |
||
215 | * |
||
216 | * @return \DateTime |
||
217 | */ |
||
218 | public function getPublishedAt() |
||
219 | { |
||
220 | if ($this->status == PageStatus::PUBLISHED && $this->publishedAt === null) { |
||
221 | $this->setPublishedAt($this->getCreatedAt()); |
||
222 | } |
||
223 | |||
224 | return $this->publishedAt; |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * Set publishedAt. |
||
229 | * |
||
230 | * @param \DateTime $publishedAt |
||
231 | * |
||
232 | * @return $this |
||
233 | */ |
||
234 | public function setPublishedAt($publishedAt) |
||
235 | { |
||
236 | $this->publishedAt = $publishedAt; |
||
0 ignored issues
–
show
It seems like
$publishedAt of type object<DateTime> is incompatible with the declared type object<Victoire\Bundle\B...Bundle\Entity\datetime> of property $publishedAt .
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. ![]() |
|||
237 | |||
238 | return $this; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * Get deletedAt. |
||
243 | * |
||
244 | * @return \DateTime |
||
245 | */ |
||
246 | public function getDeletedAt() |
||
247 | { |
||
248 | return $this->deletedAt; |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * Set deletedAt. |
||
253 | * |
||
254 | * @param \DateTime $deletedAt |
||
255 | * |
||
256 | * @return $this |
||
257 | */ |
||
258 | public function setDeletedAt($deletedAt) |
||
259 | { |
||
260 | $this->deletedAt = $deletedAt; |
||
261 | |||
262 | return $this; |
||
263 | } |
||
264 | |||
265 | /** |
||
266 | * Get the blog. |
||
267 | * |
||
268 | * @return Blog |
||
269 | */ |
||
270 | public function getBlog() |
||
271 | { |
||
272 | return $this->blog; |
||
273 | } |
||
274 | |||
275 | /** |
||
276 | * Set the blog. |
||
277 | * |
||
278 | * @param Blog $blog |
||
279 | */ |
||
280 | public function setBlog(Blog $blog) |
||
281 | { |
||
282 | $this->blog = $blog; |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * Set tags. |
||
287 | * |
||
288 | * @param string $tags |
||
289 | * |
||
290 | * @return Article |
||
291 | */ |
||
292 | public function setTags($tags) |
||
293 | { |
||
294 | $this->tags = $tags; |
||
295 | |||
296 | return $this; |
||
297 | } |
||
298 | |||
299 | /** |
||
300 | * Add tag. |
||
301 | * |
||
302 | * @param string $tag |
||
303 | * |
||
304 | * @return Article |
||
305 | */ |
||
306 | public function addTag($tag) |
||
307 | { |
||
308 | $this->tags[] = $tag; |
||
309 | |||
310 | return $this; |
||
311 | } |
||
312 | |||
313 | /** |
||
314 | * Remove tag. |
||
315 | * |
||
316 | * @param string $tag |
||
317 | * |
||
318 | * @return Article |
||
319 | */ |
||
320 | public function removeTag($tag) |
||
321 | { |
||
322 | $this->tags->removeElement($tag); |
||
323 | |||
324 | return $this; |
||
325 | } |
||
326 | |||
327 | /** |
||
328 | * Get tags. |
||
329 | * |
||
330 | * @return [Tag] |
||
0 ignored issues
–
show
The doc-type
[Tag] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
331 | */ |
||
332 | public function getTags() |
||
333 | { |
||
334 | return $this->tags; |
||
335 | } |
||
336 | |||
337 | /** |
||
338 | * Get businessEntity. |
||
339 | * |
||
340 | * @return Article |
||
341 | */ |
||
342 | public function getBusinessEntity() |
||
343 | { |
||
344 | return $this; |
||
345 | } |
||
346 | |||
347 | /** |
||
348 | * Set template. |
||
349 | * |
||
350 | * @param ArticleTemplate $template |
||
351 | * |
||
352 | * @return Article |
||
353 | */ |
||
354 | public function setTemplate(ArticleTemplate $template) |
||
355 | { |
||
356 | $this->template = $template; |
||
357 | |||
358 | return $this; |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * Get template. |
||
363 | * |
||
364 | * @return ArticleTemplate |
||
365 | */ |
||
366 | public function getTemplate() |
||
367 | { |
||
368 | return $this->template; |
||
369 | } |
||
370 | |||
371 | /** |
||
372 | * Set status. |
||
373 | * |
||
374 | * @param string $status |
||
375 | */ |
||
376 | public function setStatus($status) |
||
377 | { |
||
378 | if ($status == PageStatus::PUBLISHED && $this->publishedAt === null) { |
||
379 | $this->setPublishedAt(new \DateTime()); |
||
380 | } |
||
381 | $this->status = $status; |
||
382 | } |
||
383 | |||
384 | /** |
||
385 | * Get status. |
||
386 | * |
||
387 | * @return string |
||
388 | */ |
||
389 | public function getStatus() |
||
390 | { |
||
391 | return $this->status; |
||
392 | } |
||
393 | |||
394 | /** |
||
395 | * Get categoryTitle. |
||
396 | * |
||
397 | * @return string |
||
398 | */ |
||
399 | public function getCategoryTitle() |
||
400 | { |
||
401 | $this->categoryTitle = $this->category ? $this->category->getTitle() : null; |
||
402 | |||
403 | return $this->categoryTitle; |
||
404 | } |
||
405 | |||
406 | /** |
||
407 | * Get publishedAtString. |
||
408 | * |
||
409 | * @return string |
||
410 | */ |
||
411 | public function getPublishedAtString() |
||
412 | { |
||
413 | setlocale(LC_TIME, 'fr_FR'); |
||
414 | |||
415 | if ($this->publishedAt) { |
||
416 | return strftime('%d %B %Y', $this->publishedAt->getTimestamp()); |
||
417 | } else { |
||
418 | return ''; |
||
419 | } |
||
420 | } |
||
421 | |||
422 | /** |
||
423 | * Get author. |
||
424 | * |
||
425 | * @return string |
||
426 | */ |
||
427 | public function getAuthor() |
||
428 | { |
||
429 | return $this->author; |
||
430 | } |
||
431 | |||
432 | /** |
||
433 | * Set author. |
||
434 | * |
||
435 | * @param string $author |
||
436 | * |
||
437 | * @return $this |
||
438 | */ |
||
439 | public function setAuthor($author) |
||
440 | { |
||
441 | $this->author = $author; |
||
442 | |||
443 | return $this; |
||
444 | } |
||
445 | |||
446 | public function getAuthorAvatar() |
||
0 ignored issues
–
show
|
|||
447 | { |
||
448 | $this->authorAvatar = 'http://www.gravatar.com/avatar/'.md5($this->author->getEmail()).'?s=70'; |
||
449 | |||
450 | return $this->authorAvatar; |
||
451 | } |
||
452 | |||
453 | public function getAuthorFullname() |
||
0 ignored issues
–
show
|
|||
454 | { |
||
455 | $this->authorFullName = $this->author->getFullname(); |
||
456 | |||
457 | return $this->authorFullName; |
||
458 | } |
||
459 | |||
460 | public function setLocale($locale) |
||
0 ignored issues
–
show
|
|||
461 | { |
||
462 | $this->locale = $locale; |
||
463 | } |
||
464 | |||
465 | /** |
||
466 | * @return string |
||
467 | */ |
||
468 | public function getLocale() |
||
469 | { |
||
470 | return $this->locale; |
||
471 | } |
||
472 | |||
473 | /** |
||
474 | * @return string |
||
475 | */ |
||
476 | public function getName() |
||
477 | { |
||
478 | return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), 'getName'); |
||
479 | } |
||
480 | |||
481 | public function setName($name, $locale = null) |
||
0 ignored issues
–
show
|
|||
482 | { |
||
483 | $this->translate($locale, false)->setName($name); |
||
0 ignored issues
–
show
It seems like
setName() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
484 | $this->mergeNewTranslations(); |
||
485 | } |
||
486 | |||
487 | public function getSlug() |
||
0 ignored issues
–
show
|
|||
488 | { |
||
489 | return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), 'getSlug'); |
||
490 | } |
||
491 | |||
492 | public function setSlug($slug, $locale = null) |
||
0 ignored issues
–
show
|
|||
493 | { |
||
494 | $this->translate($locale, false)->setSlug($slug); |
||
0 ignored issues
–
show
It seems like
setSlug() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
495 | $this->mergeNewTranslations(); |
||
496 | } |
||
497 | |||
498 | public function getDescription() |
||
0 ignored issues
–
show
|
|||
499 | { |
||
500 | return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), 'getDescription'); |
||
501 | } |
||
502 | |||
503 | public function setDescription($description, $locale = null) |
||
0 ignored issues
–
show
|
|||
504 | { |
||
505 | $this->translate($locale, false)->setDescription($description); |
||
0 ignored issues
–
show
It seems like
setDescription() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
506 | $this->mergeNewTranslations(); |
||
507 | } |
||
508 | |||
509 | public function getImage() |
||
0 ignored issues
–
show
|
|||
510 | { |
||
511 | return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), 'getImage'); |
||
512 | } |
||
513 | |||
514 | public function setImage($image, $locale = null) |
||
0 ignored issues
–
show
|
|||
515 | { |
||
516 | $this->translate($locale, false)->setImage($image); |
||
0 ignored issues
–
show
It seems like
setImage() must be provided by classes using this trait. How about adding it as abstract method to this trait?
This check looks for methods that are used by a trait but not required by it. To illustrate, let’s look at the following code example trait Idable {
public function equalIds(Idable $other) {
return $this->getId() === $other->getId();
}
}
The trait Adding the ![]() |
|||
517 | $this->mergeNewTranslations(); |
||
518 | } |
||
519 | } |
||
520 |
This check marks private properties in classes that are never used. Those properties can be removed.