Newer
Older
use App\Dto\DtoInterface;
use App\Dto\NewsDetailElementDto;
use App\Dto\NewsListingElementDto;
use App\Repository\NewsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NewsRepository::class)]
class News implements PrototypeElementDto
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{
#[ORM\Id]
#[ORM\Column(type: Types::GUID)]
private ?string $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $code = null;
#[ORM\Column]
private ?int $sort = null;
#[ORM\Column]
private ?bool $active = null;
#[ORM\Column]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column]
private ?\DateTimeImmutable $updateAt = null;
#[ORM\Column(length: 1000, nullable: true)]
private ?string $previewText = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $detailText = null;
#[ORM\ManyToOne(inversedBy: 'news')]
private ?NewsType $type = null;
/**
* @var Collection<int, NewsCategories>
*/
#[ORM\ManyToMany(targetEntity: NewsCategories::class, inversedBy: 'news')]
private Collection $categories;
#[ORM\Column]
private ?bool $mainPageRender = null;
#[ORM\ManyToOne(inversedBy: 'newsDetail')]
private ?File $detailImage = null;
#[ORM\ManyToOne(inversedBy: 'newsPreview')]
private ?File $previewImage = null;
public function __construct()
{
$this->categories = new ArrayCollection();
}
public function getId(): ?string
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): static
{
$this->code = $code;
return $this;
}
public function getSort(): ?int
{
return $this->sort;
}
public function setSort(int $sort): static
{
$this->sort = $sort;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): static
{
$this->active = $active;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdateAt(): ?\DateTimeImmutable
{
return $this->updateAt;
}
public function setUpdateAt(\DateTimeImmutable $updateAt): static
{
$this->updateAt = $updateAt;
return $this;
}
public function getPreviewImage(): ?File
public function setPreviewImage(?File $previewImage): static
{
$this->previewImage = $previewImage;
return $this;
}
public function getPreviewText(): ?string
{
return $this->previewText;
}
public function setPreviewText(?string $previewText): static
{
$this->previewText = $previewText;
return $this;
}
public function getDetailImage(): ?File
public function setDetailImage(?File $detailImage): static
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
{
$this->detailImage = $detailImage;
return $this;
}
public function getDetailText(): ?string
{
return $this->detailText;
}
public function setDetailText(?string $detailText): static
{
$this->detailText = $detailText;
return $this;
}
public function getType(): ?NewsType
{
return $this->type;
}
public function setType(?NewsType $type): static
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, NewsCategories>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(NewsCategories $category): static
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
}
return $this;
}
public function removeCategory(NewsCategories $category): static
{
$this->categories->removeElement($category);
return $this;
}
public function isMainPageRender(): ?bool
{
return $this->mainPageRender;
}
public function setMainPageRender(bool $mainPageRender): static
{
$this->mainPageRender = $mainPageRender;
return $this;
}
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/** @inheritDoc */
public function getDto(): DtoInterface
{
$entity = new NewsListingElementDto();
$entity->id = $this->getId();
$entity->name = $this->getName();
$entity->description = $this->getDetailText();
$entity->image = $this->getPreviewImage()?->getDto();
$entity->create_at = $this->getCreatedAt();
$entity->detail_link = "api/v1/restaurants/" . $this->getId();
return $entity;
}
/** @inheritDoc */
public function getExtendedDto(): DtoInterface
{
$entity = new NewsDetailElementDto();
$entity->id = $this->getId();
$entity->name = $this->getName();
$entity->description = $this->getPreviewText();
$entity->text = $this->getDetailText();
$entity->image = $this->getPreviewImage()?->getDto();
$entity->create_at = $this->getCreatedAt();
return $entity;
}