1 | <?php |
||
2 | |||
3 | namespace Sludio\HelperBundle\Oauth\Configurator; |
||
4 | |||
5 | use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
||
6 | use Sludio\HelperBundle\Oauth\Client\OAuth2Client; |
||
7 | use Sludio\HelperBundle\Oauth\Client\Provider\Custom\Custom; |
||
8 | |||
9 | class CustomProviderConfigurator implements ProviderConfiguratorInterface |
||
10 | { |
||
11 | public function buildConfiguration(NodeBuilder $node) |
||
12 | { |
||
13 | // @formatter:off |
||
14 | $node |
||
15 | ->scalarNode('provider_class') |
||
16 | ->info('The class name of your provider class (e.g. the one that extends AbstractProvider)') |
||
17 | ->defaultValue(Custom::class) |
||
18 | ->end() |
||
19 | ->scalarNode('client_class') |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
20 | ->info('If you have a sub-class of OAuth2Client you want to use, add it here') |
||
21 | ->defaultValue(OAuth2Client::class) |
||
22 | ->end() |
||
23 | ->arrayNode('provider_options') |
||
24 | ->info('Other options to pass to your provider\'s constructor') |
||
25 | ->prototype('variable')->end() |
||
26 | ->end() |
||
27 | ; |
||
28 | // @formatter:on |
||
29 | } |
||
30 | |||
31 | public function getProviderClass(array $config) |
||
32 | { |
||
33 | return $config['provider_class']; |
||
34 | } |
||
35 | |||
36 | public function getProviderOptions(array $config) |
||
37 | { |
||
38 | return array_merge([ |
||
39 | 'client_id' => $config['client_id'], |
||
40 | 'client_secret' => $config['client_secret'], |
||
41 | ], $config['provider_options']); |
||
42 | } |
||
43 | |||
44 | public function getProviderDisplayName() |
||
45 | { |
||
46 | return 'Custom'; |
||
47 | } |
||
48 | |||
49 | public function getClientClass(array $config) |
||
50 | { |
||
51 | return $config['client_class']; |
||
52 | } |
||
53 | } |
||
54 |