From 5463765c917b5ac899e8c56fda3768df7702370c Mon Sep 17 00:00:00 2001 From: Xiao Hu Tai Date: Fri, 4 Jan 2019 15:30:29 +0100 Subject: [PATCH] Allow option to disable routing Since this conflicts with Bolt Translate --- config/config.yml.dist | 5 +++++ src/Routing/HierarchicalUrlGenerator.php | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/config.yml.dist b/config/config.yml.dist index 28764f3..e693935 100644 --- a/config/config.yml.dist +++ b/config/config.yml.dist @@ -45,8 +45,13 @@ rules: # # override-slugs: Allow (slugifized) names in `menu.yml` override the slugs # defined in the records. +# enable-routing: If you want to make use of hierarchies, but not the routing. +# When using Bolt Translate, the Bolt Translate routing should +# take over, so set this to `false`. Bolt Translate integration +# is not working. # settings: overwrite-duplicates : true override-slugs : false + enable-routing : true diff --git a/src/Routing/HierarchicalUrlGenerator.php b/src/Routing/HierarchicalUrlGenerator.php index 61cbeac..0ba9b98 100644 --- a/src/Routing/HierarchicalUrlGenerator.php +++ b/src/Routing/HierarchicalUrlGenerator.php @@ -38,8 +38,11 @@ public function __construct(UrlGeneratorInterface $wrapped, Application $app) */ public function generate($name, $parameters = [], $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH) { - if ($name == 'contentlink') { - $service = $this->app['hierarchicalroutes.service']; + $config = $this->app['hierarchicalroutes.config']; + $enableRouting = $config->get('settings/enable-routing', true); + + if ($enableRouting && $name == 'contentlink') { + $service = $this->app['hierarchicalroutes.service']; /** * Since Bolt 3.3. Bolt now strips away all the parameters that are not needed for the