ozo2003 /
HelperBundle
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Sludio\HelperBundle\Oauth\Configurator; |
||
| 4 | |||
| 5 | use Symfony\Component\Config\Definition\Builder\NodeBuilder; |
||
| 6 | use Sludio\HelperBundle\Oauth\Client\Provider\Twitter\Twitter; |
||
| 7 | use Sludio\HelperBundle\Oauth\Client\Client\TwitterOAuthClient; |
||
| 8 | |||
| 9 | class TwitterProviderConfigurator implements ProviderConfiguratorInterface |
||
| 10 | { |
||
| 11 | public function buildConfiguration(NodeBuilder $node) |
||
| 12 | { |
||
| 13 | // @formatter:off |
||
| 14 | $node |
||
| 15 | ->scalarNode('client_class') |
||
| 16 | ->info('If you have a sub-class of OAuth2Client you want to use, add it here') |
||
| 17 | ->defaultValue(TwitterOAuthClient::class) |
||
| 18 | ->end() |
||
| 19 | ->scalarNode('redirect_route') |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 20 | ->isRequired() |
||
| 21 | ->cannotBeEmpty() |
||
| 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 Twitter::class; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function getProviderOptions(array $config) |
||
| 37 | { |
||
| 38 | return array_merge([ |
||
| 39 | 'clientId' => $config['client_id'], |
||
| 40 | 'clientSecret' => $config['client_secret'], |
||
| 41 | 'redirect_route' => $config['redirect_route'], |
||
| 42 | ], $config['provider_options']); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function getProviderDisplayName() |
||
| 46 | { |
||
| 47 | return 'Twitter'; |
||
| 48 | } |
||
| 49 | |||
| 50 | public function getClientClass(array $config) |
||
| 51 | { |
||
| 52 | return $config['client_class']; |
||
| 53 | } |
||
| 54 | } |
||
| 55 |