Failed Conditions
Push — master ( bba1b1...f1d49a )
by Florent
05:22
created

SessionManagementRouteCompilerPass::process()   B

Complexity

Conditions 4
Paths 3

Size

Total Lines 29
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 19
nc 3
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2018 Spomky-Labs
9
 *
10
 * This software may be modified and distributed under the terms
11
 * of the MIT license.  See the LICENSE file for details.
12
 */
13
14
namespace OAuth2Framework\ServerBundle\Component\Endpoint\SessionManagement\Compiler;
15
16
use OAuth2Framework\ServerBundle\Service\MetadataBuilder;
17
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18
use Symfony\Component\DependencyInjection\ContainerBuilder;
19
20
class SessionManagementRouteCompilerPass implements CompilerPassInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function process(ContainerBuilder $container)
26
    {
27
        if (!$container->hasDefinition('oauth2_server.endpoint.session_management_pipe') || !$container->getParameter('oauth2_server.endpoint.session_management.enabled')) {
28
            return;
29
        }
30
31
        $path = $container->getParameter('oauth2_server.endpoint.session_management.path');
32
        $host = $container->getParameter('oauth2_server.endpoint.session_management.host');
33
        $route_loader = $container->getDefinition('oauth2_server.route_loader');
34
        $route_loader->addMethodCall('addRoute', [
35
            'openid_connect_iframe_endpoint',
36
            'oauth2_server.endpoint.session_management_pipe',
37
            'dispatch',
38
            $path, // path
39
            [], // defaults
40
            [], // requirements
41
            [], // options
42
            $host, // host
43
            ['https'], // schemes
44
            ['GET'], // methods
45
            '', // condition
46
        ]);
47
48
        if (!$container->hasDefinition(MetadataBuilder::class)) {
49
            return;
50
        }
51
        $medata = $container->getDefinition(MetadataBuilder::class);
52
        $medata->addMethodCall('addRoute', ['check_session_iframe', 'oauth2_server_openid_connect_iframe_endpoint']);
53
    }
54
}
55