44
55namespace Locastic \SyliusStoreLocatorPlugin \Entity ;
66
7-
7+ use Doctrine \Common \Collections \ArrayCollection ;
8+ use Doctrine \Common \Collections \Collection ;
9+ use Sylius \Component \Core \Model \ImageInterface ;
810use Sylius \Component \Resource \Model \TimestampableTrait ;
911use Sylius \Component \Resource \Model \ToggleableTrait ;
1012use Sylius \Component \Resource \Model \TranslatableTrait ;
@@ -31,11 +33,17 @@ class Store implements StoreInterface
3133
3234 protected $ address ;
3335
36+ protected $ pickupAtStoreAvailable ;
37+
38+ /** @var Collection|ImageInterface[] */
39+ protected $ images ;
40+
3441 public function __construct ()
3542 {
3643 $ this ->initializeTranslationsCollection ();
3744
3845 $ this ->createdAt = new \DateTime ();
46+ $ this ->images = new ArrayCollection ();
3947 }
4048
4149 public function getId (): ?int
@@ -179,6 +187,16 @@ public function setOpeningHours(?string $openingHours): void
179187 $ this ->getTranslation ()->setOpeningHours ($ openingHours );
180188 }
181189
190+ public function setPickupAtStoreAvailable (bool $ pickupAtStoreAvailable ): void
191+ {
192+ $ this ->pickupAtStoreAvailable = $ pickupAtStoreAvailable ;
193+ }
194+
195+ public function isPickupAtStoreAvailable (): ?bool
196+ {
197+ return $ this ->pickupAtStoreAvailable ;
198+ }
199+
182200 protected function getStoreTranslation (): StoreTranslationInterface
183201 {
184202 return $ this ->getTranslation ();
@@ -188,4 +206,37 @@ protected function createTranslation(): ?StoreTranslationInterface
188206 {
189207 return new StoreTranslation ();
190208 }
191- }
209+
210+ public function getImages (): Collection
211+ {
212+ return $ this ->images ;
213+ }
214+
215+ public function hasImages (): bool
216+ {
217+ return !$ this ->images ->isEmpty ();
218+ }
219+
220+ public function hasImage (?ImageInterface $ image ): bool
221+ {
222+ return $ this ->images ->contains ($ image );
223+ }
224+
225+ public function addImage (?ImageInterface $ image ): void
226+ {
227+ if ($ image ->hasFile ()) {
228+ $ image ->setOwner ($ this );
229+ $ this ->images ->add ($ image );
230+ }
231+ }
232+
233+ public function removeImage (ImageInterface $ image )
234+ {
235+ if ($ this ->hasImage ($ image )) {
236+ $ image ->setOwner (null );
237+ $ this ->images ->removeElement ($ image );
238+ }
239+ }
240+
241+
242+ }
0 commit comments