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