Skip to content

Commit

Permalink
Merge pull request #12 from coopTilleuls/fix_11
Browse files Browse the repository at this point in the history
Allow to override the location entity
  • Loading branch information
dunglas committed Apr 14, 2020
2 parents cfe10df + 26b7a5e commit 1899ecc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Entity/ClickNCollectShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
trait ClickNCollectShipment
{
/**
* @ORM\ManyToOne(targetEntity=CoopTilleuls\SyliusClickNCollectPlugin\Entity\Location::class)
* @ORM\ManyToOne(targetEntity=\CoopTilleuls\SyliusClickNCollectPlugin\Entity\LocationInterface::class)
*/
protected ?Location $location = null;
protected ?LocationInterface $location = null;

/**
* @ORM\Column(type="string", nullable=true)
Expand All @@ -37,7 +37,7 @@ trait ClickNCollectShipment
*/
protected ?\DateTimeInterface $collectionTime = null;

public function getLocation(): ?Location
public function getLocation(): ?LocationInterface
{
return $this->location;
}
Expand All @@ -47,7 +47,7 @@ public function isClickNCollect(): bool
return null !== $this->location && null !== $this->collectionTime;
}

public function setLocation(?Location $location): void
public function setLocation(?LocationInterface $location): void
{
$this->location = $location;
if (null !== $location && null === $this->pin && $location->isGeneratePin()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/ClickNCollectShipmentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ interface ClickNCollectShipmentInterface extends ShipmentInterface
{
public function isClickNCollect(): bool;

public function getLocation(): ?Location;
public function getLocation(): ?LocationInterface;

public function setLocation(?Location $location): void;
public function setLocation(?LocationInterface $location): void;

public function getCollectionTime(): ?\DateTimeInterface;

Expand Down
13 changes: 8 additions & 5 deletions src/Entity/ClickNCollectShippingMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
trait ClickNCollectShippingMethod
{
/**
* @var Collection|Location[]
* @var Collection|LocationInterface[]
*
* @ORM\ManyToMany(targetEntity=\CoopTilleuls\SyliusClickNCollectPlugin\Entity\Location::class, inversedBy="shippingMethods")
* @ORM\JoinTable(name="coop_tilleuls_click_n_collect_shipping_method_location")
* @ORM\ManyToMany(targetEntity=\CoopTilleuls\SyliusClickNCollectPlugin\Entity\LocationInterface::class, inversedBy="shippingMethods")
* @ORM\JoinTable(
* name="coop_tilleuls_click_n_collect_shipping_method_location",
* inverseJoinColumns={@ORM\JoinColumn(name="location_id", onDelete="cascade")}
* )
*/
protected $locations;

Expand All @@ -45,7 +48,7 @@ public function getLocations(): Collection
return $this->locations;
}

public function addLocation(Location $location): void
public function addLocation(LocationInterface $location): void
{
if (!$this->locations->contains($location)) {
$this->locations[] = $location;
Expand All @@ -57,7 +60,7 @@ public function addLocation(Location $location): void
}
}

public function removeLocation(Location $location): void
public function removeLocation(LocationInterface $location): void
{
$this->locations->removeElement($location);
$location->getShippingMethods()->removeElement($this);
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/ClickNCollectShippingMethodInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ interface ClickNCollectShippingMethodInterface extends ShippingMethodInterface
public function isClickNCollect(): bool;

/**
* @return Location[]|Collection
* @return LocationInterface[]|Collection
*/
public function getLocations(): Collection;

public function addLocation(Location $location): void;
public function addLocation(LocationInterface $location): void;

public function removeLocation(Location $location): void;
public function removeLocation(LocationInterface $location): void;
}

0 comments on commit 1899ecc

Please sign in to comment.