From 0ca8cd3e6f5136ae529c4b0d2287ada0f83da035 Mon Sep 17 00:00:00 2001 From: Lorenzo Ruozzi Date: Mon, 7 Aug 2023 12:23:08 +0200 Subject: [PATCH] Use new Symfony bundle directory structure (#63) --- UPGRADE-0.X.md | 16 ++++++++++++++++ {src/Resources/config => config}/app/config.yaml | 0 {src/Resources/config => config}/app_routing.yml | 0 .../doctrine/model/ChannelCustomer.orm.xml | 0 .../config => config}/serialization.xml | 0 {src/Resources/config => config}/services.xml | 0 .../config => config}/services/client.xml | 0 .../config => config}/services/command.xml | 0 .../config => config}/services/controller.xml | 0 .../config => config}/services/enqueuer.xml | 0 .../services/event_subscriber.xml | 0 .../config => config}/services/factory.xml | 0 .../config => config}/services/form.xml | 0 .../config => config}/services/generator.xml | 0 .../config => config}/services/http_client.xml | 0 .../config => config}/services/logger.xml | 0 .../config => config}/services/mapper.xml | 0 .../services/message_handler.xml | 0 .../config => config}/services/middleware.xml | 0 .../config => config}/services/resolver.xml | 0 .../config => config}/services/serializer.xml | 0 .../config => config}/services/twig.xml | 0 .../config => config}/services/updater.xml | 0 docs/01-Requirements.md | 3 ++- docs/02-Installation.md | 4 ++-- .../WebgriffeSyliusActiveCampaignExtension.php | 2 +- src/WebgriffeSyliusActiveCampaignPlugin.php | 12 +++++++++++- .../Admin/Channel/_form.html.twig | 0 .../Shop/_active_campaign_tracking.html.twig | 0 .../webgriffe_sylius_active_campaign_plugin.yaml | 2 +- tests/Application/config/routes.yaml | 2 +- .../messages.en.yaml | 0 .../messages.it.yaml | 0 33 files changed, 34 insertions(+), 7 deletions(-) rename {src/Resources/config => config}/app/config.yaml (100%) rename {src/Resources/config => config}/app_routing.yml (100%) rename {src/Resources/config => config}/doctrine/model/ChannelCustomer.orm.xml (100%) rename {src/Resources/config => config}/serialization.xml (100%) rename {src/Resources/config => config}/services.xml (100%) rename {src/Resources/config => config}/services/client.xml (100%) rename {src/Resources/config => config}/services/command.xml (100%) rename {src/Resources/config => config}/services/controller.xml (100%) rename {src/Resources/config => config}/services/enqueuer.xml (100%) rename {src/Resources/config => config}/services/event_subscriber.xml (100%) rename {src/Resources/config => config}/services/factory.xml (100%) rename {src/Resources/config => config}/services/form.xml (100%) rename {src/Resources/config => config}/services/generator.xml (100%) rename {src/Resources/config => config}/services/http_client.xml (100%) rename {src/Resources/config => config}/services/logger.xml (100%) rename {src/Resources/config => config}/services/mapper.xml (100%) rename {src/Resources/config => config}/services/message_handler.xml (100%) rename {src/Resources/config => config}/services/middleware.xml (100%) rename {src/Resources/config => config}/services/resolver.xml (100%) rename {src/Resources/config => config}/services/serializer.xml (100%) rename {src/Resources/config => config}/services/twig.xml (100%) rename {src/Resources/config => config}/services/updater.xml (100%) rename {src/Resources/views => templates}/Admin/Channel/_form.html.twig (100%) rename {src/Resources/views => templates}/Shop/_active_campaign_tracking.html.twig (100%) rename {src/Resources/translations => translations}/messages.en.yaml (100%) rename {src/Resources/translations => translations}/messages.it.yaml (100%) diff --git a/UPGRADE-0.X.md b/UPGRADE-0.X.md index e62a4f3..d042dc5 100644 --- a/UPGRADE-0.X.md +++ b/UPGRADE-0.X.md @@ -1,5 +1,21 @@ # UPGRADE FROM `v0.1.0` TO `v0.X` +## UPGRADE FROM `v0.6.0` TO `v0.7.0` + +The plugin directory structure has been updated to follow the Symfony bundle best practices. +Adjust your `config/packages/webgriffe_sylius_active_campaign_plugin.yaml` file by removing the word `Resources`: +```diff +- - { resource: "@WebgriffeSyliusActiveCampaignPlugin/Resources/config/app/config.yaml" } ++ - { resource: "@WebgriffeSyliusActiveCampaignPlugin/config/app/config.yaml" } +``` + +Update your route config import file by removing the word `Resources`: +```diff +webgriffe_sylius_active_campaign_shop: +- resource: "@WebgriffeSyliusActiveCampaignPlugin/Resources/config/app_routing.yml" ++ resource: "@WebgriffeSyliusActiveCampaignPlugin/config/app_routing.yml" +``` + ## UPGRADE FROM `v0.2.0` TO `v0.3.0` Adjust you entity following the subsequent PR notes, then remember to run a migration diff and run it with: diff --git a/src/Resources/config/app/config.yaml b/config/app/config.yaml similarity index 100% rename from src/Resources/config/app/config.yaml rename to config/app/config.yaml diff --git a/src/Resources/config/app_routing.yml b/config/app_routing.yml similarity index 100% rename from src/Resources/config/app_routing.yml rename to config/app_routing.yml diff --git a/src/Resources/config/doctrine/model/ChannelCustomer.orm.xml b/config/doctrine/model/ChannelCustomer.orm.xml similarity index 100% rename from src/Resources/config/doctrine/model/ChannelCustomer.orm.xml rename to config/doctrine/model/ChannelCustomer.orm.xml diff --git a/src/Resources/config/serialization.xml b/config/serialization.xml similarity index 100% rename from src/Resources/config/serialization.xml rename to config/serialization.xml diff --git a/src/Resources/config/services.xml b/config/services.xml similarity index 100% rename from src/Resources/config/services.xml rename to config/services.xml diff --git a/src/Resources/config/services/client.xml b/config/services/client.xml similarity index 100% rename from src/Resources/config/services/client.xml rename to config/services/client.xml diff --git a/src/Resources/config/services/command.xml b/config/services/command.xml similarity index 100% rename from src/Resources/config/services/command.xml rename to config/services/command.xml diff --git a/src/Resources/config/services/controller.xml b/config/services/controller.xml similarity index 100% rename from src/Resources/config/services/controller.xml rename to config/services/controller.xml diff --git a/src/Resources/config/services/enqueuer.xml b/config/services/enqueuer.xml similarity index 100% rename from src/Resources/config/services/enqueuer.xml rename to config/services/enqueuer.xml diff --git a/src/Resources/config/services/event_subscriber.xml b/config/services/event_subscriber.xml similarity index 100% rename from src/Resources/config/services/event_subscriber.xml rename to config/services/event_subscriber.xml diff --git a/src/Resources/config/services/factory.xml b/config/services/factory.xml similarity index 100% rename from src/Resources/config/services/factory.xml rename to config/services/factory.xml diff --git a/src/Resources/config/services/form.xml b/config/services/form.xml similarity index 100% rename from src/Resources/config/services/form.xml rename to config/services/form.xml diff --git a/src/Resources/config/services/generator.xml b/config/services/generator.xml similarity index 100% rename from src/Resources/config/services/generator.xml rename to config/services/generator.xml diff --git a/src/Resources/config/services/http_client.xml b/config/services/http_client.xml similarity index 100% rename from src/Resources/config/services/http_client.xml rename to config/services/http_client.xml diff --git a/src/Resources/config/services/logger.xml b/config/services/logger.xml similarity index 100% rename from src/Resources/config/services/logger.xml rename to config/services/logger.xml diff --git a/src/Resources/config/services/mapper.xml b/config/services/mapper.xml similarity index 100% rename from src/Resources/config/services/mapper.xml rename to config/services/mapper.xml diff --git a/src/Resources/config/services/message_handler.xml b/config/services/message_handler.xml similarity index 100% rename from src/Resources/config/services/message_handler.xml rename to config/services/message_handler.xml diff --git a/src/Resources/config/services/middleware.xml b/config/services/middleware.xml similarity index 100% rename from src/Resources/config/services/middleware.xml rename to config/services/middleware.xml diff --git a/src/Resources/config/services/resolver.xml b/config/services/resolver.xml similarity index 100% rename from src/Resources/config/services/resolver.xml rename to config/services/resolver.xml diff --git a/src/Resources/config/services/serializer.xml b/config/services/serializer.xml similarity index 100% rename from src/Resources/config/services/serializer.xml rename to config/services/serializer.xml diff --git a/src/Resources/config/services/twig.xml b/config/services/twig.xml similarity index 100% rename from src/Resources/config/services/twig.xml rename to config/services/twig.xml diff --git a/src/Resources/config/services/updater.xml b/config/services/updater.xml similarity index 100% rename from src/Resources/config/services/updater.xml rename to config/services/updater.xml diff --git a/docs/01-Requirements.md b/docs/01-Requirements.md index 99f6f28..0786233 100644 --- a/docs/01-Requirements.md +++ b/docs/01-Requirements.md @@ -3,4 +3,5 @@ [Return to Summary main page](README.md) * PHP `^8.0` or higher -* Sylius `^1.11` +* Sylius `^1.12` +* Symfony `^5.4` or `^6.0` diff --git a/docs/02-Installation.md b/docs/02-Installation.md index 64e2df9..ffd0acd 100644 --- a/docs/02-Installation.md +++ b/docs/02-Installation.md @@ -12,7 +12,7 @@ 3. Configure your ActiveCampaign API connection parameters by creating the `config/packages/webgriffe_sylius_active_campaign_plugin.yaml` file with the following content: ```yaml imports: - - { resource: "@WebgriffeSyliusActiveCampaignPlugin/Resources/config/app/config.yaml" } + - { resource: "@WebgriffeSyliusActiveCampaignPlugin/config/app/config.yaml" } webgriffe_sylius_active_campaign: api_client: @@ -26,7 +26,7 @@ 4. Import the routes needed for updating the list status of contact (you can omit this if you don't need to update the list status, or you don't use the list subscription feature). Add the following to your `config/routes.yaml` file: ```yaml webgriffe_sylius_active_campaign_shop: - resource: "@WebgriffeSyliusActiveCampaignPlugin/Resources/config/app_routing.yml" + resource: "@WebgriffeSyliusActiveCampaignPlugin/config/app_routing.yml" ``` Note that these routes shouldn't be inside your "shop routes", the locale parameter is not needed. diff --git a/src/DependencyInjection/WebgriffeSyliusActiveCampaignExtension.php b/src/DependencyInjection/WebgriffeSyliusActiveCampaignExtension.php index 839e4ae..0187029 100644 --- a/src/DependencyInjection/WebgriffeSyliusActiveCampaignExtension.php +++ b/src/DependencyInjection/WebgriffeSyliusActiveCampaignExtension.php @@ -18,7 +18,7 @@ final class WebgriffeSyliusActiveCampaignExtension extends AbstractResourceExten public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration($this->getConfiguration([], $container), $configs); - $fileLocator = new FileLocator(__DIR__ . '/../Resources/config'); + $fileLocator = new FileLocator(__DIR__ . '/../../config'); $loader = new XmlFileLoader($container, $fileLocator); $this->registerResources('webgriffe_sylius_active_campaign', $config['driver'], $config['resources'], $container); diff --git a/src/WebgriffeSyliusActiveCampaignPlugin.php b/src/WebgriffeSyliusActiveCampaignPlugin.php index 0b56972..98c416d 100644 --- a/src/WebgriffeSyliusActiveCampaignPlugin.php +++ b/src/WebgriffeSyliusActiveCampaignPlugin.php @@ -7,6 +7,7 @@ use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait; use Sylius\Bundle\ResourceBundle\AbstractResourceBundle; use Sylius\Bundle\ResourceBundle\SyliusResourceBundle; +use function dirname; final class WebgriffeSyliusActiveCampaignPlugin extends AbstractResourceBundle { @@ -21,11 +22,20 @@ public function getSupportedDrivers(): array public function getPath(): string { - return __DIR__; + return dirname(__DIR__); } protected function getModelNamespace(): string { return 'Webgriffe\SyliusActiveCampaignPlugin\Model'; } + + protected function getConfigFilesPath(): string + { + return sprintf( + '%s/config/doctrine/%s', + $this->getPath(), + strtolower($this->getDoctrineMappingDirectory()), + ); + } } diff --git a/src/Resources/views/Admin/Channel/_form.html.twig b/templates/Admin/Channel/_form.html.twig similarity index 100% rename from src/Resources/views/Admin/Channel/_form.html.twig rename to templates/Admin/Channel/_form.html.twig diff --git a/src/Resources/views/Shop/_active_campaign_tracking.html.twig b/templates/Shop/_active_campaign_tracking.html.twig similarity index 100% rename from src/Resources/views/Shop/_active_campaign_tracking.html.twig rename to templates/Shop/_active_campaign_tracking.html.twig diff --git a/tests/Application/config/packages/webgriffe_sylius_active_campaign_plugin.yaml b/tests/Application/config/packages/webgriffe_sylius_active_campaign_plugin.yaml index d0f23d8..afc774a 100644 --- a/tests/Application/config/packages/webgriffe_sylius_active_campaign_plugin.yaml +++ b/tests/Application/config/packages/webgriffe_sylius_active_campaign_plugin.yaml @@ -1,5 +1,5 @@ imports: - - { resource: "@WebgriffeSyliusActiveCampaignPlugin/Resources/config/app/config.yaml" } + - { resource: "@WebgriffeSyliusActiveCampaignPlugin/config/app/config.yaml" } webgriffe_sylius_active_campaign: api_client: diff --git a/tests/Application/config/routes.yaml b/tests/Application/config/routes.yaml index b8baf49..8d74370 100644 --- a/tests/Application/config/routes.yaml +++ b/tests/Application/config/routes.yaml @@ -1,2 +1,2 @@ webgriffe_sylius_active_campaign_shop: - resource: "@WebgriffeSyliusActiveCampaignPlugin/Resources/config/app_routing.yml" + resource: "@WebgriffeSyliusActiveCampaignPlugin/config/app_routing.yml" diff --git a/src/Resources/translations/messages.en.yaml b/translations/messages.en.yaml similarity index 100% rename from src/Resources/translations/messages.en.yaml rename to translations/messages.en.yaml diff --git a/src/Resources/translations/messages.it.yaml b/translations/messages.it.yaml similarity index 100% rename from src/Resources/translations/messages.it.yaml rename to translations/messages.it.yaml