1 | <?php |
||
17 | class Post |
||
18 | { |
||
19 | public const TYPE_POST = 'post'; |
||
20 | public const TYPE_FEED = 'feed'; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | * |
||
25 | * @ORM\Column(name="id", type="text") |
||
26 | * @ORM\Id |
||
27 | */ |
||
28 | private $id; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | * |
||
33 | * @ORM\Column(name="text", type="text") |
||
34 | */ |
||
35 | private $text; |
||
36 | |||
37 | /** |
||
38 | * @var \DateTime |
||
39 | * |
||
40 | * @ORM\Column(name="created_at", type="datetime") |
||
41 | */ |
||
42 | private $createdAt; |
||
43 | |||
44 | /** |
||
45 | * @var \DateTime |
||
46 | * |
||
47 | * @ORM\Column(name="updated_at", type="datetime", nullable=true) |
||
48 | */ |
||
49 | private $updatedAt; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | * |
||
54 | * @ORM\Column(name="type", type="string", length=6) |
||
55 | */ |
||
56 | private $type = self::TYPE_POST; |
||
57 | |||
58 | /** |
||
59 | * @var bool |
||
60 | * |
||
61 | * @ORM\Column(name="private", type="boolean", nullable=true) |
||
62 | */ |
||
63 | private $private; |
||
64 | |||
65 | /** |
||
66 | * @var bool |
||
67 | * |
||
68 | * @ORM\Column(name="is_deleted", type="boolean") |
||
69 | */ |
||
70 | private $deleted = false; |
||
71 | |||
72 | /** |
||
73 | * @var User |
||
74 | * |
||
75 | * @ORM\ManyToOne(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\User") |
||
76 | * @ORM\JoinColumn(name="author") |
||
77 | */ |
||
78 | private $author; |
||
79 | |||
80 | /** |
||
81 | * @var File[]|ArrayCollection |
||
82 | * |
||
83 | * @ORM\ManyToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\File", fetch="EXTRA_LAZY", cascade={"persist"}) |
||
84 | * @ORM\JoinTable(name="posts_files", schema="posts", |
||
85 | * joinColumns={@ORM\JoinColumn(name="post_id")}, |
||
86 | * inverseJoinColumns={@ORM\JoinColumn(name="file_id")} |
||
87 | * ) |
||
88 | */ |
||
89 | private $files; |
||
90 | |||
91 | /** |
||
92 | * @var Tag[]|ArrayCollection |
||
93 | * |
||
94 | * @ORM\OneToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\PostTag", mappedBy="post", fetch="EXTRA_LAZY", cascade={"persist"}, orphanRemoval=true) |
||
95 | */ |
||
96 | private $postTags; |
||
97 | |||
98 | /** |
||
99 | * @var Comment[]|ArrayCollection |
||
100 | * |
||
101 | * @ORM\OneToMany(targetEntity="Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment", mappedBy="post", cascade={"persist"}) |
||
102 | */ |
||
103 | private $comments; |
||
104 | |||
105 | |||
106 | public function __construct(string $id, User $author, \DateTime $createdAt, string $type) |
||
117 | |||
118 | /** |
||
119 | * @ORM\PreUpdate |
||
120 | */ |
||
121 | public function preUpdate(): void |
||
125 | |||
126 | public function getId(): string |
||
130 | |||
131 | public function setText(string $text): self |
||
137 | |||
138 | public function getText(): string |
||
142 | |||
143 | public function getCreatedAt(): \DateTime |
||
147 | |||
148 | public function getUpdatedAt(): ?\DateTime |
||
152 | |||
153 | public function getType(): string |
||
157 | 1 | ||
158 | public function getAuthor(): User |
||
162 | |||
163 | public function addFile(File $files): self |
||
169 | |||
170 | public function removeFile(File $files): void |
||
174 | |||
175 | /** |
||
176 | * @return File[]|ArrayCollection |
||
177 | */ |
||
178 | public function getFiles(): iterable |
||
182 | 1 | ||
183 | public function addPostTag(PostTag $tag): self |
||
190 | |||
191 | public function removePostTag(PostTag $tag): void |
||
195 | |||
196 | /** |
||
197 | * @return PostTag[]|ArrayCollection |
||
198 | */ |
||
199 | public function getPostTags(): iterable |
||
203 | |||
204 | public function setDeleted(bool $deleted): self |
||
210 | |||
211 | public function getDeleted(): bool |
||
215 | |||
216 | public function isDeleted(): bool |
||
220 | |||
221 | 1 | public function setPrivate(bool $private): self |
|
227 | |||
228 | public function isPrivate(): bool |
||
232 | |||
233 | public function getPrivate(): bool |
||
237 | |||
238 | public function addComment(Comment $comment): self |
||
245 | |||
246 | public function removeComment(Comment $comment): void |
||
250 | |||
251 | /** |
||
252 | * @return Comment[]|ArrayCollection |
||
253 | */ |
||
254 | public function getComments(): iterable |
||
258 | } |
||
259 |