SilexJSRoutingServiceProvider::getDefaults()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace rootLogin\JSRoutingProvider\Provider;
4
5
use rootLogin\JSRoutingProvider\Command\DumpJSCommand;
6
use rootLogin\JSRoutingProvider\Command\DumpRouterCommand;
7
use Silex\Application;
8
use Silex\ServiceProviderInterface;
9
10
class SilexJSRoutingServiceProvider implements ServiceProviderInterface
11
{
12
    public function register(Application $app)
13
    {
14
        foreach ($this->getDefaults() as $key => $value) {
15
            if (!isset($app[$key])) {
16
                $app[$key] = $value;
17
            }
18
        }
19
20
        $app->mount($app['jsrouting.base_url'], new SilexJSRoutingControllerProvider());
21
    }
22
23
    public function boot(Application $app)
24
    {
25
        if(isset($app['console'])) {
26
            $console = $app['console'];
27
            if(get_class($console) == "Saxulum\Console\Console\ConsoleApplication") {
28
                /** @var \Saxulum\Console\Console\ConsoleApplication $console */
29
                $console->add(new DumpJSCommand());
30
                $console->add(new DumpRouterCommand());
31
            }
32
        }
33
    }
34
35
    public function getDefaults() {
36
        return array(
37
            "jsrouting.base_url" => "/",
38
            "jsrouting.exposed_routes" => array(),
39
        );
40
    }
41
}
42