diff --git a/docker-compose.yaml.dist b/docker-compose.yaml.dist index 955683c..24d6f0c 100644 --- a/docker-compose.yaml.dist +++ b/docker-compose.yaml.dist @@ -1,4 +1,3 @@ -version: '3.8' services: database: image: mysql:8.0 diff --git a/src/Form/Type/Settings/NoCommerceType.php b/src/Form/Type/Settings/NoCommerceType.php index 6347a04..fed2ab5 100644 --- a/src/Form/Type/Settings/NoCommerceType.php +++ b/src/Form/Type/Settings/NoCommerceType.php @@ -14,7 +14,7 @@ namespace MonsieurBiz\SyliusNoCommercePlugin\Form\Type\Settings; use MonsieurBiz\SyliusNoCommercePlugin\Firewall\RegistryInterface; -use MonsieurBiz\SyliusNoCommercePlugin\Provider\FeaturesProvider; +use MonsieurBiz\SyliusNoCommercePlugin\Model\ConfigInterface; use MonsieurBiz\SyliusSettingsPlugin\Form\AbstractSettingsType; use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; @@ -35,6 +35,7 @@ public function __construct(RegistryInterface $firewallRegistry) /** * @SuppressWarnings(PHPMD.UnusedFormalParameter) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ public function buildForm(FormBuilderInterface $builder, array $options): void { @@ -61,20 +62,29 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'multiple' => true, 'choices' => $choices, ]); - $this->addWithDefaultCheckbox($builder, 're_enabled_admin_routes', ChoiceType::class, [ - 'label' => 'monsieurbiz.nocommerce.ui.form.field.re_enabled_admin_routes.label', - 'required' => false, - 'multiple' => true, - 'choices' => [ - 'sylius.ui.countries' => FeaturesProvider::COUNTRIES_KEY, - 'sylius.ui.currencies' => FeaturesProvider::CURRENCIES_KEY, - 'sylius.ui.inventory' => FeaturesProvider::INVENTORY_KEY, - 'sylius.ui.payment' => FeaturesProvider::PAYMENT_KEY, - 'sylius.menu.admin.main.catalog.header' => FeaturesProvider::CATALOG_KEY, - 'sylius.ui.shipping' => FeaturesProvider::SHIPPING_KEY, - 'sylius.ui.tax' => FeaturesProvider::TAX_KEY, - 'sylius.ui.zones' => FeaturesProvider::ZONES_KEY, - ], - ]); + + if ($this->isDefaultForm($builder)) { + $this->addWithDefaultCheckbox($builder, 'routes_to_enable', ChoiceType::class, [ + 'label' => 'monsieurbiz.nocommerce.ui.form.field.routes_to_enable.label', + 'required' => false, + 'multiple' => true, + 'expanded' => false, + 'choices' => $this->getEnabledRouteChoices(), + ]); + } + } + + private function getEnabledRouteChoices(): array + { + $allRoutes = ConfigInterface::ROUTES_BY_GROUP; + $choices = []; + + foreach ($allRoutes as $group => $routes) { + foreach ($routes as $route) { + $choices[$group][$route] = $route; + } + } + + return $choices; } } diff --git a/src/Kernel/SyliusNoCommerceKernelTrait.php b/src/Kernel/SyliusNoCommerceKernelTrait.php index 73fbc9e..2e61921 100644 --- a/src/Kernel/SyliusNoCommerceKernelTrait.php +++ b/src/Kernel/SyliusNoCommerceKernelTrait.php @@ -13,8 +13,10 @@ namespace MonsieurBiz\SyliusNoCommercePlugin\Kernel; +use Exception; use MonsieurBiz\SyliusNoCommercePlugin\Model\Config; use MonsieurBiz\SyliusNoCommercePlugin\Model\ConfigInterface; +use MonsieurBiz\SyliusNoCommercePlugin\Provider\FeaturesProviderInterface; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Routing\RouteCollection; @@ -25,186 +27,6 @@ trait SyliusNoCommerceKernelTrait MicroKernelTrait::loadRoutes as parentLoadRoutes; } - private array $routesToRemove = [ - // Customers & Account & Users - 'customer' => [ - 'sylius_admin_partial_customer', - 'sylius_admin_customer', - 'api_customer', - 'sylius_shop_log', - 'sylius_shop_register', - 'sylius_shop_request_password_reset_token', - 'sylius_shop_password_reset', - 'sylius_shop_user_request_verification_token', - 'sylius_shop_user_verification', - 'sylius_shop_account', - 'api_register_shop_users_post_collection', - 'sylius_api_shop_authentication_token', - 'sylius_shop_ajax_user_check_action', - ], - - // Products - 'product' => [ - 'sylius_admin_product', - 'sylius_admin_api_product', - 'sylius_admin_ajax_product', - 'sylius_shop_partial_product', - 'sylius_shop_product', - 'sylius_admin_partial_product', - 'sylius_admin_ajax_generate_product_slug', - 'api_product', - ], - - // Taxons - 'taxon' => [ - 'sylius_admin_partial_taxon', - 'sylius_admin_ajax_taxon', - 'sylius_admin_taxon', - 'sylius_admin_api_taxon', - 'sylius_shop_partial_taxon', - 'sylius_admin_ajax_generate_taxon_slug', - 'sylius_shop_partial_channel_menu_taxon_index', - 'api_taxon', - ], - - // Checkout - 'checkout' => [ - 'sylius_admin_api_checkout', - 'sylius_shop_checkout', - 'sylius_shop_register_after_checkout', - ], - - // Addresses - 'address' => [ - 'sylius_shop_account_address', - 'sylius_admin_partial_address', - ], - - // Orders - 'order' => [ - 'sylius_admin_order', - 'sylius_admin_api_order', - 'sylius_shop_account_order', - 'sylius_shop_order', - 'sylius_admin_partial_order', - 'sylius_admin_customer_order', - 'sylius_admin_api_customer_order', - 'api_order', - ], - - // Adjustments - 'adjustment' => [ - 'sylius_admin_api_adjustment', - 'sylius_shop_ajax_render_province_form', - 'api_adjustment', - ], - - // Promotions - 'promotion' => [ - 'sylius_admin_partial_promotion', - 'sylius_admin_promotion', - 'sylius_admin_api_promotion', - 'api_promo', - ], - - // Shipping and Shipments - 'shipment' => [ - 'sylius_admin_partial_shipment', - 'sylius_admin_ship', - 'sylius_admin_api_ship', - 'api_ship', - ], - - // Inventory - 'inventory' => [ - 'sylius_admin_inventory', - ], - - // Attributes - 'attribute' => [ - 'sylius_admin_get_attribute_types', - 'sylius_admin_get_product_attributes', - 'sylius_admin_render_attribute_forms', - ], - - // Payments - 'payment' => [ - 'sylius_admin_payment', - 'sylius_admin_get_payment', - 'payum_', - 'sylius_admin_api_payment', - 'api_pay', - ], - - // PayPal - 'paypal' => [ - 'sylius_paypal', - ], - - // Taxes - 'tax' => [ - 'sylius_admin_tax_', - 'sylius_admin_api_tax_', - 'api_tax', - ], - - // Currencies - 'currency' => [ - 'sylius_admin_currency', - 'sylius_admin_api_currency', - 'sylius_shop_switch_currency', - 'api_currencies', - ], - - // Exchange rates - 'exchange' => [ - 'sylius_admin_exchange', - 'sylius_admin_api_exchange', - 'api_exchange', - ], - - // Zones - 'zone' => [ - 'sylius_admin_zone', - 'sylius_admin_api_zone', - 'api_zone', - ], - - // Countries - 'country' => [ - 'sylius_admin_country', - 'sylius_admin_api_country', - 'api_countries', - ], - - // Provinces - 'province' => [ - 'sylius_admin_api_province', - 'sylius_admin_ajax_render_province_form', - 'api_province', - ], - - // Carts - 'cart' => [ - 'sylius_admin_api_cart', - 'sylius_shop_ajax_cart', - 'sylius_shop_partial_cart', - 'sylius_shop_cart', - 'api_cart', - ], - - // Dashboard - 'dashboard' => [ - 'sylius_admin_dashboard_statistics', - ], - - // Others - 'other' => [ - 'api_shop_billing', - 'api_channels_shop', - ], - ]; - /** * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ @@ -216,7 +38,7 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection foreach ($collection as $name => $route) { foreach ($routesToRemove as $routeToRemove) { if (false !== strpos($name, $routeToRemove)) { - $route->setCondition('not context.checkNoCommerce(params)'); + $route->setCondition('not context.checkNoCommerce()'); } } } @@ -239,27 +61,58 @@ private function getConfig(): ConfigInterface * * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - private function getRoutesToRemove(): array + public function getRoutesToRemove(): array { $config = $this->getConfig(); $routesToRemove = []; + $this->routesToRemove = ConfigInterface::ROUTES_BY_GROUP; + /** @deprecated */ if ($config->areCustomersAllowed()) { unset($this->routesToRemove['customer']); } + /** @deprecated */ if ($config->areZonesAllowed()) { unset($this->routesToRemove['zone']); } + /** @deprecated */ if ($config->areZonesAllowed() || $config->areCountriesAllowed()) { unset($this->routesToRemove['country']); } + // Loop on settings to add routes + /** @var FeaturesProviderInterface $featuresProvider */ + $featuresProvider = $this->container->get('monsieurbiz.no_commerce.provider.features_provider'); + + try { + $routesToEnable = $featuresProvider->getRoutesToEnable(); + } catch (Exception $e) { + $routesToEnable = []; + } + + foreach ($routesToEnable as $route) { + $this->enableRoute($route); + } + foreach ($this->routesToRemove as $routes) { $routesToRemove = array_merge($routesToRemove, $routes); } return $routesToRemove; } + + private function enableRoute(string $route): void + { + foreach ($this->routesToRemove as $group => $routes) { + if (false !== ($key = array_search($route, $routes, true))) { + unset($this->routesToRemove[$group][$key]); + } + + if (empty($this->routesToRemove[$group])) { + unset($this->routesToRemove[$group]); + } + } + } } diff --git a/src/Menu/AdminMenuListener.php b/src/Menu/AdminMenuListener.php index 116cb9b..a6a8b91 100644 --- a/src/Menu/AdminMenuListener.php +++ b/src/Menu/AdminMenuListener.php @@ -14,24 +14,29 @@ namespace MonsieurBiz\SyliusNoCommercePlugin\Menu; use Knp\Menu\ItemInterface; -use MonsieurBiz\SyliusNoCommercePlugin\Model\ConfigInterface; use MonsieurBiz\SyliusNoCommercePlugin\Provider\FeaturesProviderInterface; use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent; +use Symfony\Component\Routing\Route; +use Symfony\Component\Routing\RouteCollection; +use Symfony\Component\Routing\RouterInterface; final class AdminMenuListener { - private ConfigInterface $config; - private FeaturesProviderInterface $featuresProvider; + private RouterInterface $router; + public function __construct( - ConfigInterface $config, - FeaturesProviderInterface $featuresProvider + FeaturesProviderInterface $featuresProvider, + RouterInterface $router ) { - $this->config = $config; $this->featuresProvider = $featuresProvider; + $this->router = $router; } + /** + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + */ public function __invoke(MenuBuilderEvent $event): void { $menu = $event->getMenu(); @@ -40,80 +45,56 @@ public function __invoke(MenuBuilderEvent $event): void return; } - $menu->removeChild('sales'); + // We loop on all items and check if each route is enabled or not + // If the route is disabled, we remove the menu item + // If all children are removed, we remove the parent menu item - $this->handleCatalogMenu($menu); - $menu->removeChild('marketing'); + // Retrieve all avaible routes + $routes = $this->router->getRouteCollection(); - if (!$this->config->areCustomersAllowed()) { - $menu->removeChild('customers'); - } + // Loop on level 1 menu items + foreach ($menu->getChildren() as $childMenu) { + // Loop on level 2 menu items + foreach ($childMenu->getChildren() as $menuItem) { + // Remove menu item if route is disabled + $this->removeChildIfRoutesDisabled($childMenu, $menuItem->getName(), $routes); + } - if (null !== $configuration = $menu->getChild('configuration')) { - $this->removeConfigurationChildren($configuration); + // Remove parent menu item if no child left + if (0 === \count($childMenu->getChildren())) { + $menu->removeChild($childMenu->getName()); + } } } - private function removeConfigurationChildren(ItemInterface $configuration): void - { - $this->removeChildIfRoutesDisabled($configuration, 'currencies'); - - if (!$this->config->areZonesAllowed() && !$this->config->areCountriesAllowed()) { - $this->removeChildIfRoutesDisabled($configuration, 'countries'); - } - if (!$this->config->areZonesAllowed()) { - $this->removeChildIfRoutesDisabled($configuration, 'zones'); - } - - $configuration->removeChild('exchange_rates'); - $this->removeChildIfRoutesDisabled($configuration, 'payment_methods'); - $this->removeChildIfRoutesDisabled($configuration, 'shipping_methods'); - $this->removeChildIfRoutesDisabled($configuration, 'shipping_categories'); - $this->removeChildIfRoutesDisabled($configuration, 'tax_categories'); - $this->removeChildIfRoutesDisabled($configuration, 'tax_rates'); - } - /** - * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * If the route in the menu items matches a route that is disabled, remove the menu item. + * We now that the route is disabled if the condition contains "not context.checkNoCommerce()". */ - private function removeChildIfRoutesDisabled(ItemInterface $menu, string $menuName): void + private function removeChildIfRoutesDisabled(ItemInterface $menu, string $menuName, RouteCollection $routes): void { $menuItem = $menu->getChild($menuName); if (!$menuItem || null === $menuItem->getExtra('routes')) { return; } - foreach ($menuItem->getExtra('routes') as $route) { - if (!isset($route['route'])) { - continue; - } - // If one route does not match the forced enabled routes, we remove the menu item - if (!$this->featuresProvider->isRouteForcedEnabled(['_route' => $route['route']])) { - $menu->removeChild($menuName); - } + $route = $this->getRouteByUri((string) $menuItem->getUri(), $routes); + if (false !== strpos((string) $route?->getCondition(), 'not context.checkNoCommerce()')) { + $menu->removeChild($menuName); } } - private function handleCatalogMenu(ItemInterface $menu): void + /** + * @SuppressWarnings(PHPMD.UnusedLocalVariable) + */ + private function getRouteByUri(string $uri, RouteCollection $routes): ?Route { - $catalogMenu = $menu->getChild('catalog'); - - if (null === $catalogMenu) { - return; - } - - $this->removeChildIfRoutesDisabled($catalogMenu, 'taxons'); - $this->removeChildIfRoutesDisabled($catalogMenu, 'products'); - $this->removeChildIfRoutesDisabled($catalogMenu, 'inventory'); - $this->removeChildIfRoutesDisabled($catalogMenu, 'attributes'); - $this->removeChildIfRoutesDisabled($catalogMenu, 'options'); - $this->removeChildIfRoutesDisabled($catalogMenu, 'association_types'); - - // We remove the catalog menu if it has no children - if ($catalogMenu->hasChildren()) { - return; + foreach ($routes as $name => $route) { + if ($uri === $route->getPath()) { + return $route; + } } - $menu->removeChild('catalog'); + return null; } } diff --git a/src/Model/ConfigInterface.php b/src/Model/ConfigInterface.php index 3b49eec..e13d0f0 100644 --- a/src/Model/ConfigInterface.php +++ b/src/Model/ConfigInterface.php @@ -15,6 +15,180 @@ interface ConfigInterface { + public const ROUTES_BY_GROUP = [ + /** + * Customers & Account & Users. + */ + 'customer_admin' => [ + 'sylius_admin_partial_customer', + 'sylius_admin_customer', + ], + 'customer_shop' => [ + 'sylius_shop_log', + 'sylius_shop_register', + 'sylius_shop_request_password_reset_token', + 'sylius_shop_password_reset', + 'sylius_shop_user_request_verification_token', + 'sylius_shop_user_verification', + 'sylius_shop_account', + 'sylius_shop_ajax_user_check_action', + ], + 'customer_api' => [ + 'api_customer', + 'api_register_shop_users_post_collection', + 'sylius_api_shop_authentication_token', + ], + /** + * Catalog. + */ + 'catalog_admin' => [ + 'sylius_admin_product', + 'sylius_admin_ajax_product', + 'sylius_admin_partial_product', + 'sylius_admin_ajax_generate_product_slug', + 'sylius_admin_partial_taxon', + 'sylius_admin_ajax_taxon', + 'sylius_admin_taxon', + 'sylius_admin_ajax_generate_taxon_slug', + 'sylius_admin_get_attribute_types', + 'sylius_admin_get_product_attributes', + 'sylius_admin_render_attribute_forms', + 'sylius_admin_inventory', + 'sylius_admin_tax_', + 'sylius_admin_api_tax_', + ], + 'catalog_shop' => [ + 'sylius_shop_partial_product', + 'sylius_shop_product', + 'sylius_shop_partial_taxon', + 'sylius_shop_partial_channel_menu_taxon_index', + ], + 'catalog_api' => [ + 'sylius_admin_api_product', + 'api_product', + 'sylius_admin_api_taxon', + 'api_taxon', + 'api_tax', + ], + /** + * Addresses. + */ + 'address_shop' => [ + 'sylius_shop_account_address', + 'sylius_shop_ajax_render_province_form', + ], + /** + * Orders. + */ + 'order_admin' => [ + 'sylius_admin_order', + 'sylius_admin_partial_order', + 'sylius_admin_customer_order', + 'sylius_admin_partial_address', + 'sylius_admin_partial_promotion', + 'sylius_admin_promotion', + 'sylius_admin_catalog_promotion', + 'sylius_admin_partial_shipment', + 'sylius_admin_ship', + 'sylius_admin_payment', + 'sylius_admin_get_payment', + 'sylius_admin_api_cart', + ], + 'order_shop' => [ + 'sylius_shop_account_order', + 'sylius_shop_order', + 'payum_', + 'sylius_paypal', + 'sylius_shop_ajax_cart', + 'sylius_shop_partial_cart', + 'sylius_shop_cart', + 'sylius_shop_checkout', + 'sylius_shop_register_after_checkout', + ], + 'order_api' => [ + 'sylius_admin_api_adjustment', + 'sylius_admin_api_order', + 'sylius_admin_api_customer_order', + 'api_order', + 'api_adjustment', + 'sylius_admin_api_promotion', + 'api_promo', + 'sylius_admin_api_ship', + 'api_ship', + 'sylius_admin_api_payment', + 'api_pay', + 'api_cart', + 'sylius_admin_api_checkout', + ], + /** + * Currencies. + */ + 'currency_admin' => [ + 'sylius_admin_currency', + 'sylius_admin_api_currency', + ], + 'currency_shop' => [ + 'sylius_shop_switch_currency', + ], + 'currency_api' => [ + 'api_currencies', + ], + /** + * Exchange rates. + */ + 'exchange_admin' => [ + 'sylius_admin_exchange', + 'sylius_admin_api_exchange', + 'api_exchange', + ], + 'exchange_api' => [ + 'api_exchange', + ], + /** + * Zones. + */ + 'zone_admin' => [ + 'sylius_admin_zone', + 'sylius_admin_api_zone', + ], + 'zone_api' => [ + 'api_zone', + ], + /** + * Countries. + */ + 'country_admin' => [ + 'sylius_admin_country', + 'sylius_admin_api_country', + ], + 'country_api' => [ + 'api_countries', + ], + /** + * Province. + */ + 'province_admin' => [ + 'sylius_admin_api_province', + 'sylius_admin_ajax_render_province_form', + ], + 'province_api' => [ + 'api_province', + ], + /** + * Dashboard. + */ + 'dashboard' => [ + 'sylius_admin_dashboard_statistics', + ], + /** + * Billing data. + */ + 'billing_data' => [ + 'api_shop_billing', + 'api_channels_shop', + ], + ]; + public function areCountriesAllowed(): bool; public function areCustomersAllowed(): bool; diff --git a/src/Provider/FeaturesProvider.php b/src/Provider/FeaturesProvider.php index 5a788f4..0ae1751 100644 --- a/src/Provider/FeaturesProvider.php +++ b/src/Provider/FeaturesProvider.php @@ -20,60 +20,6 @@ final class FeaturesProvider implements FeaturesProviderInterface { - public const COUNTRIES_KEY = 'countries'; - - public const CURRENCIES_KEY = 'currencies'; - - public const INVENTORY_KEY = 'inventory'; - - public const PAYMENT_KEY = 'payment'; - - public const CATALOG_KEY = 'catalog'; - - public const SHIPPING_KEY = 'shipping'; - - public const TAX_KEY = 'tax'; - - public const ZONES_KEY = 'zones'; - - public const ADMIN_ROUTES_THAT_CAN_BE_RE_ENABLED = [ - self::COUNTRIES_KEY => [ - 'sylius_admin_country', - 'sylius_admin_ajax_render_province_form', - ], - self::CURRENCIES_KEY => [ - 'sylius_admin_currency', - ], - self::INVENTORY_KEY => [ - 'sylius_admin_inventory', - ], - self::PAYMENT_KEY => [ - 'sylius_admin_payment_method', - ], - self::CATALOG_KEY => [ - 'sylius_admin_get_attribute_types', - 'sylius_admin_get_product_attributes', - 'sylius_admin_render_attribute_forms', - 'sylius_admin_product', - 'sylius_admin_ajax_product', - 'sylius_admin_partial_product', - 'sylius_admin_ajax_generate_product_slug', - 'sylius_admin_partial_taxon', - 'sylius_admin_ajax_taxon', - 'sylius_admin_taxon', - 'sylius_admin_ajax_generate_taxon_slug', - ], - self::SHIPPING_KEY => [ - 'sylius_admin_shipping', - ], - self::TAX_KEY => [ - 'sylius_admin_tax_', - ], - self::ZONES_KEY => [ - 'sylius_admin_zone', - ], - ]; - private ChannelContextInterface $channelContext; private SettingsInterface $nocommerceSettings; @@ -103,36 +49,8 @@ public function isNoCommerceEnabledForChannel(?ChannelInterface $channel = null) return (bool) $this->nocommerceSettings->getCurrentValue($channel, null, 'enabled'); } - /** - * @SuppressWarnings(PHPMD.CyclomaticComplexity) - */ - public function isRouteForcedEnabled(array $params = []): bool + public function getRoutesToEnable(): array { - if (!isset($params['_route'])) { - return false; - } - - $route = $params['_route']; - $channel = $this->channelContext->getChannel(); - /** @var ?array $reEnabledAdminRoutes */ - $reEnabledAdminRoutes = $this->nocommerceSettings->getCurrentValue($channel, null, 're_enabled_admin_routes'); - - if (empty($reEnabledAdminRoutes)) { - return false; - } - - // We are checking if we should re-enable the route - foreach ($reEnabledAdminRoutes as $reEnabledAdminSection) { - if (!isset(self::ADMIN_ROUTES_THAT_CAN_BE_RE_ENABLED[$reEnabledAdminSection])) { - continue; - } - foreach (self::ADMIN_ROUTES_THAT_CAN_BE_RE_ENABLED[$reEnabledAdminSection] as $reEnabledAdminRoute) { - if (false !== strpos($route, $reEnabledAdminRoute)) { - return true; - } - } - } - - return false; + return $this->nocommerceSettings->getCurrentValue(null, null, 'routes_to_enable') ?? []; } } diff --git a/src/Provider/FeaturesProviderInterface.php b/src/Provider/FeaturesProviderInterface.php index 66e23e2..3cc139a 100644 --- a/src/Provider/FeaturesProviderInterface.php +++ b/src/Provider/FeaturesProviderInterface.php @@ -19,5 +19,5 @@ interface FeaturesProviderInterface { public function isNoCommerceEnabledForChannel(?ChannelInterface $channel = null): bool; - public function isRouteForcedEnabled(array $params = []): bool; + public function getRoutesToEnable(): array; } diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 8e2982c..7978200 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -6,6 +6,6 @@ monsieurbiz: disabled_firewall_contexts: label: Firewalls to be disabled enabled: - label: Enabled - re_enabled_admin_routes: - label: Admin routes to re-enable + label: Enabled, clear cache after modification + routes_to_enable: + label: 'Route to enable, clear cache after modification (⚠️ Beta: this feature is under development)' diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 6d0f060..ad9ebab 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -6,6 +6,6 @@ monsieurbiz: disabled_firewall_contexts: label: Firewalls à désactiver enabled: - label: Activer - re_enabled_admin_routes: - label: Routes à réactiver pour l'admin + label: Activer, vider le cache après modification + routes_to_enable: + label: 'Routes à réactiver, vider le cache après modification (⚠️ Bêta : cette fonctionnalité est en cours de développement)' diff --git a/src/Routing/NoCommerceRequestContext.php b/src/Routing/NoCommerceRequestContext.php index fac318b..90710c9 100644 --- a/src/Routing/NoCommerceRequestContext.php +++ b/src/Routing/NoCommerceRequestContext.php @@ -41,9 +41,9 @@ public function __construct( $this->featuresProvider = $featuresProvider; } - public function checkNoCommerce(array $params = []): bool + public function checkNoCommerce(): bool { - return $this->featuresProvider->isNoCommerceEnabledForChannel() && !$this->featuresProvider->isRouteForcedEnabled($params); + return $this->featuresProvider->isNoCommerceEnabledForChannel(); } /**