Skip to content

Commit

Permalink
Merge pull request #21 from delyriand/feature/add-documentation
Browse files Browse the repository at this point in the history
Add installation instructions in README
  • Loading branch information
delyriand authored Mar 13, 2024
2 parents 013df60 + 112e97b commit f5dd715
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 7 deletions.
148 changes: 144 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,155 @@ This plugin allows you to choose a delivery date and time.

## Installation

⚙️ To Be Defined.
Install the plugin with `composer`:

### Migrations
`composer require monsieurbiz/sylius-shipping-slot-plugin`

Migrations are taken care of by Doctrine 3.
If you are using Symfony Flex, the recipe will automatically do some actions.

You should just run them:
<details>
<summary>For the installation without Flex, follow these additional steps</summary>
<p>
1. Add the plugin to your `config/bundles.php` file:

```php
return [
// ...
MonsieurBiz\SyliusShippingSlotPlugin\MonsieurBizSyliusShippingSlotPlugin::class => ['all' => true],
];
```

2. Import the plugin's configuration by creating a new file `config/packages/monsieurbiz_sylius_shipping_slot_plugin.yaml` with the following content:

```yaml
imports:
- { resource: "@MonsieurBizSyliusShippingSlotPlugin/Resources/config/config.yaml" }
```
3. Import the plugin's routing by creating a new file `config/routes/monsieurbiz_sylius_shipping_slot_plugin.yaml` with the following content:

```yaml
monsieurbiz_sylius_shipping_slot_plugin:
resource: "@MonsieurBizSyliusShippingSlotPlugin/Resources/config/routing.yaml"
```

4. Copy the override template from the plugin to your `templates` directory:

```bash
mkdir -p templates/bundles/; cp -Rv vendor/monsieurbiz/sylius-shipping-slot-plugin/src/Resources/views/SyliusShopBundle templates/bundles/
````
</p>
</details>
After that, follow the next steps:
1. Your `Order` entity should implement the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderInterface` and use the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderTrait` trait:

```diff
namespace App\Entity\Order;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderInterface as MonsieurBizOrderInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\OrderTrait;
use Sylius\Component\Core\Model\Order as BaseOrder;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_order")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_order')]
-class Order extends BaseOrder
+class Order extends BaseOrder implements MonsieurBizOrderInterface
{
+ use OrderTrait;
}
```

2. Your `ProductVariant` entity should implement the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantInterface` and use the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantTrait` trait:

```diff
namespace App\Entity\Product;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantInterface as MonsieurBizProductVariantInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ProductVariantTrait;
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant;
use Sylius\Component\Product\Model\ProductVariantTranslationInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_product_variant")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_product_variant')]
-class ProductVariant extends BaseProductVariant
+class ProductVariant extends BaseProductVariant implements MonsieurBizProductVariantInterface
{
+ use ProductVariantTrait;
+
protected function createTranslation(): ProductVariantTranslationInterface
{
return new ProductVariantTranslation();
}
}
```

3. Your `Shipment` entity should implement the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentInterface` and use the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentTrait` trait:

```diff
namespace App\Entity\Shipping;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentInterface as MonsieurBizShipmentInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShipmentTrait;
use Sylius\Component\Core\Model\Shipment as BaseShipment;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_shipment")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_shipment')]
-class Shipment extends BaseShipment
+class Shipment extends BaseShipment implements MonsieurBizShipmentInterface
{
+ use ShipmentTrait;
}
```

4. Your `ShippingMethod` entity should implement the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodInterface` and use the `MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodTrait` trait:

```diff
namespace App\Entity\Shipping;
use Doctrine\ORM\Mapping as ORM;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodInterface as MonsieurBizShippingMethodInterface;
+use MonsieurBiz\SyliusShippingSlotPlugin\Entity\ShippingMethodTrait;
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
use Sylius\Component\Shipping\Model\ShippingMethodTranslationInterface;
/**
* @ORM\Entity
* @ORM\Table(name="sylius_shipping_method")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_shipping_method')]
-class ShippingMethod extends BaseShippingMethod
+class ShippingMethod extends BaseShippingMethod implements MonsieurBizShippingMethodInterface
{
+ use ShippingMethodTrait;
+
protected function createTranslation(): ShippingMethodTranslationInterface
{
return new ShippingMethodTranslation();
}
}
```

5. Update your database schema with the following command:

```bash
bin/console doctrine:migrations:migrate
```

Expand Down
1 change: 1 addition & 0 deletions src/Form/Type/ShippingSlotConfigType.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
'allow_add' => true,
'allow_delete' => true,
'help' => 'monsieurbiz_shipping_slot.ui.form.rrules_help',
'help_html' => true,
])
->add('preparationDelay', IntegerType::class, [
'label' => 'monsieurbiz_shipping_slot.ui.form.preparation_delay',
Expand Down
40 changes: 40 additions & 0 deletions src/Migrations/Version20240313134140.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

/*
* This file is part of Monsieur Biz' Shipping Slot plugin for Sylius.
*
* (c) Monsieur Biz <[email protected]>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace MonsieurBiz\SyliusShippingSlotPlugin\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240313134140 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE monsieurbiz_shipping_slot_config CHANGE rrules rrules JSON DEFAULT NULL');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE monsieurbiz_shipping_slot_config CHANGE rrules rrules LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\'');
}
}
2 changes: 1 addition & 1 deletion src/Resources/config/sylius/ui.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sylius_ui:
events:
# Admin shipping method form - Add shipping slot configuration fiel
# Admin shipping method form - Add shipping slot configuration field
sylius.admin.shipping_method.update.form:
blocks:
shipping_slot_configuration: '@MonsieurBizSyliusShippingSlotPlugin/Admin/Form/ShippingMethod/shipping_slot_configuration.html.twig'
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/translations/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ monsieurbiz_shipping_slot:
name: 'Configuration''s name'
timezone: 'Timezone'
rrules: 'Recurrence rules'
rrules_help: 'You can define a new RRULE with the help of <a href="https://jakubroztocil.github.io/rrule/">the online demo</a>.'
rrules_help: 'You can define a new RRULE with the help of <a href="https://jkbrzt.github.io/rrule/" target="_blank" rel="noreferrer noopener">the online demo</a>.'
preparation_delay: 'Preparation delay (in minutes)'
pickup_delay: 'Pickup delay (in minutes)'
duration_range: 'Duration range of the slot (in minutes)'
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/translations/messages.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ monsieurbiz_shipping_slot:
name: 'Nom de la configuration'
timezone: 'Fuseau horaire'
rrules: 'Règles de récurrence'
rrules_help: 'Vous pouvez définir une nouvelle RRULE avec l''aide de <a href="https://jakubroztocil.github.io/rrule/">la démo en ligne</a>.'
rrules_help: 'Vous pouvez définir une nouvelle RRULE avec l''aide de <a href="https://jkbrzt.github.io/rrule/" target="_blank" rel="noreferrer noopener">la démo en ligne</a>.'
preparation_delay: 'Délai de préparation (en minutes)'
pickup_delay: 'Délai de retrait (en minutes)'
duration_range: 'Durée du créneau (en minutes)'
Expand Down

0 comments on commit f5dd715

Please sign in to comment.