Skip to content

Commit bc8e565

Browse files
committed
Support client options
1 parent 1307649 commit bc8e565

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

README.md

+7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ calliostro_spotify_web_api:
7171
# Your Client Secret
7272
client_secret: '' # Required
7373

74+
# Options for SpotifyWebAPI client
75+
# https://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/setting-options.md
76+
options:
77+
auto_refresh: false
78+
auto_retry: false
79+
return_assoc: false
80+
7481
# Address to redirect to after authentication success OR failure
7582
redirect_uri: '' # Example: 'https://127.0.0.1:8000/callback/'
7683

src/DependencyInjection/CalliostroSpotifyWebApiExtension.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function load(array $configs, ContainerBuilder $container)
2727
->replaceArgument(0, new Reference('calliostro_spotify_web_api.session'));
2828

2929
$container->getDefinition('calliostro_spotify_web_api')
30-
->replaceArgument(0, new Reference($config['token_provider']));
30+
->replaceArgument(0, new Reference($config['token_provider']))
31+
->replaceArgument(1, $config['options']);
3132
}
3233
}

src/DependencyInjection/Configuration.php

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ public function getConfigTreeBuilder(): TreeBuilder
2121
->info('Your Client Secret')
2222
->defaultValue('')
2323
->end()
24+
->arrayNode('options')
25+
->info("Options for SpotifyWebAPI client\nhttps://github.com/jwilsson/spotify-web-api-php/blob/main/docs/examples/setting-options.md")
26+
->addDefaultsIfNotSet()
27+
->children()
28+
->booleanNode('auto_refresh')->defaultFalse()->end()
29+
->booleanNode('auto_retry')->defaultFalse()->end()
30+
->booleanNode('return_assoc')->defaultFalse()->end()
31+
->end()
32+
->end()
2433
->scalarNode('redirect_uri')
2534
->info('Address to redirect to after authentication success OR failure')
2635
->example('https://127.0.0.1:8000/callback/')

src/Resources/config/services.xml

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<service id="calliostro_spotify_web_api" class="SpotifyWebAPI\SpotifyWebAPI" public="true">
1919
<factory class="Calliostro\SpotifyWebApiBundle\SpotifyWebApiFactory" method="factory" />
2020
<argument />
21+
<argument />
2122
</service>
2223

2324
<service id="SpotifyWebAPI\Session" alias="calliostro_spotify_web_api.session" public="false" />

src/SpotifyWebApiFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
final class SpotifyWebApiFactory
88
{
9-
public static function factory(TokenProviderInterface $tokenProvider): SpotifyWebAPI
9+
public static function factory(TokenProviderInterface $tokenProvider, array $options = []): SpotifyWebAPI
1010
{
11-
$api = new SpotifyWebAPI();
11+
$api = new SpotifyWebAPI($options);
1212
$api->setAccessToken($tokenProvider->getAccessToken());
1313

1414
return $api;

0 commit comments

Comments
 (0)