process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 2
nop 1
dl 0
loc 21
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * The MIT License (MIT)
7
 *
8
 * Copyright (c) 2014-2019 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\ClientConfiguration\Compiler;
15
16
use OAuth2Framework\Component\ClientConfigurationEndpoint\ClientConfigurationEndpoint;
17
use OAuth2Framework\ServerBundle\Routing\RouteLoader;
18
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
21
class ClientConfigurationEndpointRouteCompilerPass implements CompilerPassInterface
22
{
23
    public function process(ContainerBuilder $container): void
24
    {
25
        if (!$container->hasDefinition(ClientConfigurationEndpoint::class)) {
26
            return;
27
        }
28
29
        $path = $container->getParameter('oauth2_server.endpoint.client_configuration.path');
30
        $host = $container->getParameter('oauth2_server.endpoint.client_configuration.host');
31
        $route_loader = $container->getDefinition(RouteLoader::class);
32
        $route_loader->addMethodCall('addRoute', [
33
            'client_configuration',
34
            'client_configuration_endpoint_pipe',
35
            'dispatch',
36
            $path, // path
37
            [], // defaults
38
            [], // requirements
39
            [], // options
40
            $host, // host
41
            ['https'], // schemes
42
            ['GET', 'PUT', 'DELETE'], // methods
43
            '', // condition
44
        ]);
45
    }
46
}
47