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 Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement; |
15
|
|
|
|
16
|
|
|
use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source; |
17
|
|
|
use Jose\Component\Console\JKULoaderCommand; |
18
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
19
|
|
|
use Symfony\Component\Config\FileLocator; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; |
22
|
|
|
|
23
|
|
|
class JKUSource implements Source |
24
|
|
|
{ |
25
|
|
|
public function name(): string |
26
|
|
|
{ |
27
|
|
|
return 'jku_factory'; |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
31
|
|
|
{ |
32
|
|
|
if (true === $configs[$this->name()]['enabled']) { |
33
|
|
|
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../../../Resources/config')); |
34
|
|
|
$loader->load('jku_source.php'); |
35
|
|
|
if (class_exists(JKULoaderCommand::class)) { |
36
|
|
|
$loader->load('jku_commands.php'); |
37
|
|
|
} |
38
|
|
|
$container->setAlias('jose.http_client', $configs[$this->name()]['client']); |
39
|
|
|
$container->setAlias('jose.request_factory', $configs[$this->name()]['request_factory']); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function getNodeDefinition(NodeDefinition $node): void |
44
|
|
|
{ |
45
|
|
|
$node |
46
|
|
|
->children() |
47
|
|
|
->arrayNode('jku_factory') |
48
|
|
|
->canBeEnabled() |
49
|
|
|
->children() |
50
|
|
|
->scalarNode('client') |
51
|
|
|
->info('HTTP Client used to retrieve key sets.') |
52
|
|
|
->isRequired() |
53
|
|
|
->defaultNull() |
54
|
|
|
->end() |
55
|
|
|
->scalarNode('request_factory') |
56
|
|
|
->info('The request factory service.') |
57
|
|
|
->isRequired() |
58
|
|
|
->end() |
59
|
|
|
->end() |
60
|
|
|
->end() |
61
|
|
|
->end() |
62
|
|
|
; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
66
|
|
|
{ |
67
|
|
|
return []; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|