|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace ProjetNormandie\ArticleBundle\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
8
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
9
|
|
|
|
|
10
|
|
|
#[ORM\Table(name:'pna_article_translation')] |
|
11
|
|
|
#[ORM\Entity] |
|
12
|
|
|
#[ORM\EntityListeners(["ProjetNormandie\ArticleBundle\EventListener\Entity\ArticleTranslationListener"])] |
|
13
|
|
|
#[ORM\UniqueConstraint(name: 'article_translation_unique', columns: ['translatable_id', 'locale'])] |
|
14
|
|
|
class ArticleTranslation |
|
15
|
|
|
{ |
|
16
|
|
|
#[ORM\Id, ORM\Column, ORM\GeneratedValue] |
|
17
|
|
|
private ?int $id = null; |
|
18
|
|
|
|
|
19
|
|
|
#[ORM\ManyToOne(targetEntity: Article::class, inversedBy: 'translations')] |
|
20
|
|
|
#[ORM\JoinColumn(name: 'translatable_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] |
|
21
|
|
|
private ?Article $translatable = null; |
|
22
|
|
|
|
|
23
|
|
|
#[ORM\Column(length: 5)] |
|
24
|
|
|
private string $locale; |
|
25
|
|
|
|
|
26
|
|
|
#[Assert\NotBlank] |
|
27
|
|
|
#[ORM\Column(length: 255, nullable: false)] |
|
28
|
|
|
private string $title = ''; |
|
29
|
|
|
|
|
30
|
|
|
#[Assert\NotBlank] |
|
31
|
|
|
#[ORM\Column(type: 'text', nullable: false)] |
|
32
|
|
|
private string $text = ''; |
|
33
|
|
|
|
|
34
|
|
|
public function __toString(): string |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->title ?: ''; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function getId(): ?int |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->id; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getTranslatable(): ?Article |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->translatable; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function setTranslatable(?Article $translatable): void |
|
50
|
|
|
{ |
|
51
|
|
|
$this->translatable = $translatable; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function getLocale(): string |
|
55
|
|
|
{ |
|
56
|
|
|
return $this->locale; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function setLocale(string $locale): void |
|
60
|
|
|
{ |
|
61
|
|
|
$this->locale = $locale; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function getTitle(): string |
|
65
|
|
|
{ |
|
66
|
|
|
return $this->title; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function setTitle(string $title): void |
|
70
|
|
|
{ |
|
71
|
|
|
$this->title = $title; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
public function getText(): string |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->text; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function setText(string $text): void |
|
80
|
|
|
{ |
|
81
|
|
|
$this->text = $text; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|