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 | /** |
||
107 | * Post constructor. |
||
108 | * @param string $id |
||
109 | */ |
||
110 | public function __construct($id) |
||
118 | |||
119 | /** |
||
120 | * @ORM\PreUpdate |
||
121 | */ |
||
122 | public function preUpdate(): void |
||
126 | |||
127 | public function getId(): string |
||
131 | |||
132 | public function setText(string $text): self |
||
138 | |||
139 | public function getText(): string |
||
143 | |||
144 | public function setCreatedAt(\DateTime $createdAt): self |
||
150 | |||
151 | public function getCreatedAt(): \DateTime |
||
155 | |||
156 | public function getUpdatedAt(): ?\DateTime |
||
160 | |||
161 | public function setType(string $type): self |
||
167 | |||
168 | public function getType(): string |
||
172 | |||
173 | public function getAuthor(): User |
||
177 | |||
178 | public function setAuthor(User $author): self |
||
184 | |||
185 | public function addFile(File $files): self |
||
191 | |||
192 | public function removeFile(File $files): void |
||
196 | |||
197 | /** |
||
198 | * Get files |
||
199 | * |
||
200 | * @return File[]|ArrayCollection |
||
201 | */ |
||
202 | public function getFiles() |
||
206 | |||
207 | public function addPostTag(PostTag $tag): self |
||
214 | |||
215 | public function removePostTag(PostTag $tag): void |
||
219 | 1 | ||
220 | /** |
||
221 | 1 | * Get tags |
|
222 | * |
||
223 | * @return PostTag[]|ArrayCollection |
||
224 | */ |
||
225 | public function getPostTags() |
||
229 | |||
230 | public function setDeleted(bool $deleted): self |
||
236 | |||
237 | public function getDeleted(): bool |
||
241 | |||
242 | public function isDeleted(): bool |
||
246 | |||
247 | public function setPrivate(bool $private): self |
||
253 | |||
254 | public function isPrivate(): bool |
||
258 | |||
259 | public function getPrivate(): bool |
||
263 | |||
264 | 1 | public function addComment(Comment $comment): self |
|
271 | |||
272 | public function removeComment(Comment $comment): void |
||
276 | |||
277 | /** |
||
278 | * Get comments |
||
279 | * |
||
280 | * @return Comment[]|ArrayCollection |
||
281 | */ |
||
282 | public function getComments() |
||
286 | } |
||
287 |