Completed
Push — 0.3.x ( 921e84...1e8c09 )
by Dmitry
14:16
created

SsoRoutesLoader::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Krtv\Bundle\SingleSignOnIdentityProviderBundle\Routing;
4
5
use Symfony\Component\Config\Loader\LoaderInterface;
6
use Symfony\Component\Config\Loader\LoaderResolverInterface;
7
use Symfony\Component\Routing\Route;
8
use Symfony\Component\Routing\RouteCollection;
9
10
/**
11
 * Class SsoRoutesLoader
12
 * @package Krtv\Bundle\SingleSignOnIdentityProviderBundle\Routing
13
 */
14
class SsoRoutesLoader implements LoaderInterface
15
{
16
    /**
17
     * @var string
18
     */
19
    private $ssoHost;
20
21
    /**
22
     * @var string
23
     */
24
    private $ssoLoginPath;
25
26
    /**
27
     * @var string
28
     */
29
    private $ssoLogoutPath;
30
31
    /**
32
     * @param string $ssoHost
33
     * @param string $ssoLoginPath
34
     * @param string $ssoLogoutPath
35
     */
36 4
    public function __construct($ssoHost, $ssoLoginPath, $ssoLogoutPath)
37
    {
38 4
        $this->ssoHost = $ssoHost;
39 4
        $this->ssoLoginPath = $ssoLoginPath;
40 4
        $this->ssoLogoutPath = $ssoLogoutPath;
41 4
    }
42
43
    /**
44
     * @param string $resource
45
     * @param string $type
46
     * @return RouteCollection
47
     */
48 2
    public function load($resource, $type = null)
49
    {
50 2
        $route1 = new Route($this->ssoLoginPath, array(
51
            '_controller' => 'KrtvSingleSignOnIdentityProviderBundle:SingleSignOn:ssoLogin'
52 2
        ), array(), array(), $this->ssoHost);
53
54 2
        $route2 = new Route($this->ssoLogoutPath, array(
55
            '_controller' => 'KrtvSingleSignOnIdentityProviderBundle:SingleSignOn:ssoLogout'
56 2
        ), array(), array(), $this->ssoHost);
57
58 2
        $routes = new RouteCollection();
59 2
        $routes->add('sso_login_path', $route1);
60 2
        $routes->add('sso_logout_path', $route2);
61
62 2
        return $routes;
63
    }
64
65
    /**
66
     * @param string $resource
67
     * @param string $type
68
     * @return bool
69
     */
70 2
    public function supports($resource, $type = null)
71
    {
72 2
        return $type === 'sso';
73
    }
74
75
    /**
76
     * @return void
77
     */
78 1
    public function getResolver()
79
    {
80 1
    }
81
82
    /**
83
     * Irrelevant to us, since we don't need a resolver
84
     *
85
     * @param LoaderResolverInterface $resolver
86
     */
87 2
    public function setResolver(LoaderResolverInterface $resolver)
88
    {
89 2
    }
90
}
91