summaryrefslogtreecommitdiff
path: root/src/Routing/RoutingServiceProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Routing/RoutingServiceProvider.php')
-rw-r--r--src/Routing/RoutingServiceProvider.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Routing/RoutingServiceProvider.php b/src/Routing/RoutingServiceProvider.php
index b7db1383..beaa6a94 100644
--- a/src/Routing/RoutingServiceProvider.php
+++ b/src/Routing/RoutingServiceProvider.php
@@ -1,14 +1,24 @@
<?php
-
namespace Engelsystem\Routing;
use Engelsystem\Container\ServiceProvider;
+/**
+ * Registers the url generator depending on config.
+ */
class RoutingServiceProvider extends ServiceProvider
{
+
public function register()
{
- $urlGenerator = $this->app->make(UrlGenerator::class);
+ $config = $this->app->get('config');
+ $class = UrlGenerator::class;
+ if (! $config->get('rewrite_urls', true)) {
+ $class = LegacyUrlGenerator::class;
+ }
+
+ $urlGenerator = $this->app->make($class);
$this->app->instance('routing.urlGenerator', $urlGenerator);
+ $this->app->bind(UrlGeneratorInterface::class, 'routing.urlGenerator');
}
}