summaryrefslogtreecommitdiff
path: root/src/Routing/RoutingServiceProvider.php
blob: beaa6a9490e580ea7111d670305a2d887a9fd3ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace Engelsystem\Routing;

use Engelsystem\Container\ServiceProvider;

/**
 * Registers the url generator depending on config.
 */
class RoutingServiceProvider extends ServiceProvider
{

    public function register()
    {
        $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');
    }
}