From 4cabdd01c81a64ea7b5b9d9e3fc65f88ab54a9e0 Mon Sep 17 00:00:00 2001 From: Maxime Leclercq Date: Mon, 18 Mar 2024 11:56:46 +0100 Subject: [PATCH 1/2] feat: allow overriding entities --- src/Entity/ShippingSlotConfig.php | 18 +++++++++--------- src/Entity/Slot.php | 14 +++++++------- .../config/doctrine/ShippingSlotConfig.orm.xml | 4 ++-- src/Resources/config/doctrine/Slot.orm.xml | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Entity/ShippingSlotConfig.php b/src/Entity/ShippingSlotConfig.php index 8428657..6edcdf3 100644 --- a/src/Entity/ShippingSlotConfig.php +++ b/src/Entity/ShippingSlotConfig.php @@ -27,23 +27,23 @@ class ShippingSlotConfig implements ShippingSlotConfigInterface { - private ?int $id = null; + protected ?int $id = null; - private ?string $name = null; + protected ?string $name = null; - private ?string $timezone = null; + protected ?string $timezone = null; - private ?array $rrules = null; + protected ?array $rrules = null; - private ?int $preparationDelay = null; + protected ?int $preparationDelay = null; - private ?int $pickupDelay = null; + protected ?int $pickupDelay = null; - private ?int $durationRange = null; + protected ?int $durationRange = null; - private ?int $availableSpots = null; + protected ?int $availableSpots = null; - private ?string $color = null; + protected ?string $color = null; public function getId(): ?int { diff --git a/src/Entity/Slot.php b/src/Entity/Slot.php index 2c0fcc0..eb7fbf4 100644 --- a/src/Entity/Slot.php +++ b/src/Entity/Slot.php @@ -23,19 +23,19 @@ class Slot implements SlotInterface { use TimestampableTrait; - private ?int $id = null; + protected ?int $id = null; - private ?DateTimeInterface $timestamp = null; + protected ?DateTimeInterface $timestamp = null; - private ?int $preparationDelay = null; + protected ?int $preparationDelay = null; - private ?int $pickupDelay = null; + protected ?int $pickupDelay = null; - private ?int $durationRange = null; + protected ?int $durationRange = null; - private ?ShipmentInterface $shipment = null; + protected ?ShipmentInterface $shipment = null; - private ?ShippingSlotConfigInterface $shippingSlotConfig = null; + protected ?ShippingSlotConfigInterface $shippingSlotConfig = null; public function getId(): ?int { diff --git a/src/Resources/config/doctrine/ShippingSlotConfig.orm.xml b/src/Resources/config/doctrine/ShippingSlotConfig.orm.xml index 5636807..6b2f902 100644 --- a/src/Resources/config/doctrine/ShippingSlotConfig.orm.xml +++ b/src/Resources/config/doctrine/ShippingSlotConfig.orm.xml @@ -1,7 +1,7 @@ - + @@ -13,5 +13,5 @@ - + diff --git a/src/Resources/config/doctrine/Slot.orm.xml b/src/Resources/config/doctrine/Slot.orm.xml index 04fb42a..056ac19 100644 --- a/src/Resources/config/doctrine/Slot.orm.xml +++ b/src/Resources/config/doctrine/Slot.orm.xml @@ -1,7 +1,7 @@ - + @@ -21,5 +21,5 @@ - + From c149471c5cab1d1a75fb145240db873ed53e649d Mon Sep 17 00:00:00 2001 From: Maxime Leclercq Date: Mon, 18 Mar 2024 11:57:01 +0100 Subject: [PATCH 2/2] test: example of overriding entities --- ...nsieurbiz_sylius_shipping_slot_plugin.yaml | 6 +++++ .../Entity/Shipping/ShippingSlotConfig.php | 26 +++++++++++++++++++ dist/src/Entity/Shipping/Slot.php | 26 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 dist/src/Entity/Shipping/ShippingSlotConfig.php create mode 100644 dist/src/Entity/Shipping/Slot.php diff --git a/dist/config/packages/monsieurbiz_sylius_shipping_slot_plugin.yaml b/dist/config/packages/monsieurbiz_sylius_shipping_slot_plugin.yaml index 7442023..6382230 100644 --- a/dist/config/packages/monsieurbiz_sylius_shipping_slot_plugin.yaml +++ b/dist/config/packages/monsieurbiz_sylius_shipping_slot_plugin.yaml @@ -4,3 +4,9 @@ imports: monsieurbiz_sylius_shipping_slot: expiration: slot: '30 minutes' + +sylius_resource: + resources: + monsieurbiz_shipping_slot.slot: + classes: + model: App\Entity\Shipping\Slot diff --git a/dist/src/Entity/Shipping/ShippingSlotConfig.php b/dist/src/Entity/Shipping/ShippingSlotConfig.php new file mode 100644 index 0000000..61b1726 --- /dev/null +++ b/dist/src/Entity/Shipping/ShippingSlotConfig.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace App\Entity\Shipping; + +use Doctrine\ORM\Mapping as ORM; +use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingSlotConfig as BaseShippingSlotConfig; + +/** + * @ORM\Entity + * @ORM\Table(name="monsieurbiz_shipping_slot_config") + */ +final class ShippingSlotConfig extends BaseShippingSlotConfig +{ + +} diff --git a/dist/src/Entity/Shipping/Slot.php b/dist/src/Entity/Shipping/Slot.php new file mode 100644 index 0000000..ba50e45 --- /dev/null +++ b/dist/src/Entity/Shipping/Slot.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace App\Entity\Shipping; + +use Doctrine\ORM\Mapping as ORM; +use MonsieurBiz\SyliusShippingSlotPlugin\Entity\Slot as BaseSlot; + +/** + * @ORM\Entity + * @ORM\Table(name="monsieurbiz_shipping_slot_slot") + */ +final class Slot extends BaseSlot +{ + +}