Failed Conditions
Push — ng ( 7180d6...8c4fca )
by Florent
04:12
created

ClientRegistrationEndpointRouteCompilerPass   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 34
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B process() 0 28 3
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\Bundle\Component\Endpoint\ClientRegistration\Compiler;
15
16
use OAuth2Framework\Bundle\Routing\RouteLoader;
17
use OAuth2Framework\Bundle\Service\MetadataBuilder;
18
use OAuth2Framework\Component\ClientRegistrationEndpoint\ClientRegistrationEndpoint;
19
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
22
class ClientRegistrationEndpointRouteCompilerPass implements CompilerPassInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function process(ContainerBuilder $container)
28
    {
29
        if (!$container->hasDefinition(ClientRegistrationEndpoint::class)) {
30
            return;
31
        }
32
33
        $path = $container->getParameter('oauth2_server.endpoint.client_registration.path');
34
        $route_loader = $container->getDefinition(RouteLoader::class);
35
        $route_loader->addMethodCall('addRoute', [
36
            'client_registration',
37
            'client_registration_endpoint_pipe',
38
            'dispatch',
39
            $path, // path
40
            [], // defaults
41
            [], // requirements
42
            [], // options
43
            '', // host
44
            ['https'], // schemes
45
            ['POST'], // methods
46
            '', // condition
47
        ]);
48
49
        if (!$container->hasDefinition(MetadataBuilder::class)) {
50
            return;
51
        }
52
        $definition = $container->getDefinition(MetadataBuilder::class);
53
        $definition->addMethodCall('addRoute', ['registration_endpoint', 'oauth2_server_client_registration']);
54
    }
55
}
56