1 | <?php |
||
19 | class News |
||
20 | { |
||
21 | /** |
||
22 | * @ORM\Column(type="integer") |
||
23 | * @ORM\Id |
||
24 | * @ORM\GeneratedValue(strategy="AUTO") |
||
25 | */ |
||
26 | protected $id; |
||
27 | |||
28 | /** |
||
29 | * @ORM\Column(type="string", length=100) |
||
30 | */ |
||
31 | protected $title; |
||
32 | |||
33 | /** |
||
34 | * @ORM\Column(type="string", length=100, nullable=true) |
||
35 | */ |
||
36 | protected $subtitle; |
||
37 | |||
38 | /** |
||
39 | * @ORM\Column(type="date", nullable=true) |
||
40 | */ |
||
41 | protected $date; |
||
42 | |||
43 | /** |
||
44 | * @ORM\Column(type="boolean") |
||
45 | */ |
||
46 | protected $visible = false; |
||
47 | |||
48 | /** |
||
49 | * @ORM\Column(type="datetime", name="created_at") |
||
50 | */ |
||
51 | protected $createdAt; |
||
52 | |||
53 | /** |
||
54 | * @ORM\Column(type="text", name="creator_email") |
||
55 | */ |
||
56 | protected $creatorEmail; |
||
57 | |||
58 | /** |
||
59 | * @ORM\Column(length=255, nullable=true) |
||
60 | * @Uploadable\Uploadable(targetField="photo") |
||
61 | */ |
||
62 | protected $photoKey; |
||
63 | |||
64 | /** |
||
65 | * @var \FSi\DoctrineExtensions\Uploadable\File|\SplFileInfo |
||
66 | * @UploadableAssert\Image() |
||
67 | */ |
||
68 | protected $photo; |
||
69 | |||
70 | /** |
||
71 | * @var Category[]|Collection |
||
72 | * |
||
73 | * @ORM\ManyToMany(targetEntity="Category") |
||
74 | */ |
||
75 | protected $categories; |
||
76 | |||
77 | /** |
||
78 | * @var Tag[]|Collection |
||
79 | * |
||
80 | * @Assert\Valid |
||
81 | * @ORM\OneToMany(targetEntity="Tag", mappedBy="news", cascade={"persist"}, orphanRemoval=true) |
||
82 | */ |
||
83 | protected $tags; |
||
84 | |||
85 | public function __construct() |
||
91 | |||
92 | public function getId(): ?int |
||
96 | |||
97 | public function setCreatedAt(DateTimeInterface $createdAt): void |
||
101 | |||
102 | public function getCreatedAt(): ?DateTimeInterface |
||
106 | |||
107 | public function setCreatorEmail(?string $creatorEmail): void |
||
111 | |||
112 | public function getCreatorEmail(): ?string |
||
116 | |||
117 | public function setTitle(?string $title): void |
||
121 | |||
122 | public function getTitle(): ?string |
||
126 | |||
127 | public function setSubtitle(?string $subtitle): void |
||
131 | |||
132 | public function getSubtitle(): ?string |
||
136 | |||
137 | public function setDate(?DateTimeInterface $date): void |
||
141 | |||
142 | public function getDate(): ?DateTimeInterface |
||
146 | |||
147 | public function setVisible(bool $visible): void |
||
151 | |||
152 | public function isVisible(): bool |
||
156 | |||
157 | public function getPhotoKey(): ?string |
||
161 | |||
162 | public function setPhotoKey(?string $photoKey): void |
||
166 | |||
167 | /** |
||
168 | * @return \FSi\DoctrineExtensions\Uploadable\File|\SplFileInfo |
||
169 | */ |
||
170 | public function getPhoto() |
||
174 | |||
175 | /** |
||
176 | * @param \FSi\DoctrineExtensions\Uploadable\File|\SplFileInfo $photo |
||
177 | */ |
||
178 | public function setPhoto($photo): void |
||
182 | |||
183 | public function addCategory(Category $category): void |
||
187 | |||
188 | public function removeCategory(Category $category): void |
||
192 | |||
193 | /** |
||
194 | * @return Category[] |
||
195 | */ |
||
196 | public function getCategories(): array |
||
200 | |||
201 | /** |
||
202 | * @return Tag[]|Collection |
||
203 | */ |
||
204 | public function getTags(): Collection |
||
208 | |||
209 | public function addTag(Tag $tag): void |
||
216 | |||
217 | public function removeTag(Tag $tag): void |
||
222 | |||
223 | public function setTags(array $tags): void |
||
227 | } |
||
228 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: