Skip to content

Commit ff4bcc9

Browse files
authored
Merge pull request #3 from Locastic/pickup-at-location
[wip] init pickupAtStore option
2 parents 6660b8c + 87c64d4 commit ff4bcc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1133
-14
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": "^7.1",
1414

15-
"sylius/sylius": "^1.1"
15+
"sylius/sylius": "1.1.*"
1616
},
1717
"require-dev": {
1818
"behat/behat": "^3.3",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
4+
5+
interface IsPickupAtStoreInterface
6+
{
7+
public function isPickupAtStore(): ?bool;
8+
9+
public function setPickupAtStore(bool $pickupAtLocation): void;
10+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
4+
5+
trait IsPickupAtStoreTrait
6+
{
7+
protected $pickupAtStore;
8+
9+
public function isPickupAtStore(): ?bool
10+
{
11+
return $this->pickupAtStore;
12+
}
13+
14+
public function setPickupAtStore(bool $pickupAtStore): void
15+
{
16+
$this->pickupAtStore = $pickupAtStore;
17+
}
18+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
6+
7+
interface PickupAtStoreInterface
8+
{
9+
public function getStore(): ?StoreInterface;
10+
11+
public function setStore(?StoreInterface $store): void;
12+
}

src/Entity/PickupAtStoreTrait.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
6+
7+
trait PickupAtStoreTrait
8+
{
9+
protected $store;
10+
11+
public function getStore(): ?StoreInterface
12+
{
13+
return $this->store;
14+
}
15+
16+
public function setStore(?StoreInterface $store): void
17+
{
18+
$this->store = $store;
19+
}
20+
}

src/Entity/Shipment.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
4+
5+
use Sylius\Component\Core\Model\Shipment as BaseShipment;
6+
7+
class Shipment extends BaseShipment implements PickupAtStoreInterface
8+
{
9+
use PickupAtStoreTrait;
10+
}

src/Entity/ShippingMethod.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
4+
5+
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
6+
use Sylius\Component\Shipping\Model\ShippingMethodTranslationInterface;
7+
8+
class ShippingMethod extends BaseShippingMethod implements IsPickupAtStoreInterface
9+
{
10+
use IsPickupAtStoreTrait;
11+
12+
public function __construct()
13+
{
14+
parent::__construct();
15+
16+
$this->pickupAtStore = false;
17+
}
18+
19+
protected function createTranslation(): ShippingMethodTranslationInterface
20+
{
21+
return parent::createTranslation();
22+
}
23+
}

src/Entity/Store.php

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
66

7-
7+
use Doctrine\Common\Collections\ArrayCollection;
8+
use Doctrine\Common\Collections\Collection;
9+
use Sylius\Component\Core\Model\ImageInterface;
810
use Sylius\Component\Resource\Model\TimestampableTrait;
911
use Sylius\Component\Resource\Model\ToggleableTrait;
1012
use 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+
}

src/Entity/StoreImage.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
6+
7+
use Sylius\Component\Core\Model\Image;
8+
9+
class StoreImage extends Image implements StoreImageInterface
10+
{
11+
12+
}

src/Entity/StoreImageInterface.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Locastic\SyliusStoreLocatorPlugin\Entity;
6+
7+
use Sylius\Component\Core\Model\ImageInterface;
8+
9+
interface StoreImageInterface extends ImageInterface
10+
{
11+
}

0 commit comments

Comments
 (0)