1 | <?php |
||
22 | class PKCEMethodCompilerPass implements CompilerPassInterface |
||
23 | { |
||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | */ |
||
27 | public function process(ContainerBuilder $container) |
||
28 | { |
||
29 | if (!$container->hasDefinition(PKCEMethodManager::class)) { |
||
30 | return; |
||
31 | } |
||
32 | |||
33 | $definition = $container->getDefinition(PKCEMethodManager::class); |
||
34 | |||
35 | $taggedServices = $container->findTaggedServiceIds('oauth2_server_pkce_method'); |
||
36 | $loaded = []; |
||
37 | foreach ($taggedServices as $id => $tags) { |
||
38 | foreach ($tags as $attributes) { |
||
39 | if (!array_key_exists('alias', $attributes)) { |
||
40 | throw new \InvalidArgumentException(sprintf('The PKCE method "%s" does not have any "alias" attribute.', $id)); |
||
41 | } |
||
42 | $loaded[] = $attributes['alias']; |
||
43 | $definition->addMethodCall('add', [new Reference($id)]); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | if (!$container->hasDefinition(MetadataBuilder::class)) { |
||
48 | return; |
||
49 | } |
||
50 | |||
51 | $definition = $container->getDefinition(MetadataBuilder::class); |
||
52 | $definition->addMethodCall('setCodeChallengeMethodsSupported', [new Reference(PKCEMethodManager::class)]); |
||
53 | } |
||
55 |