commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ProviderFactory.php
1 <?php
2 
3 declare(strict_types=1);
4 
5 namespace Commercetools\Client;
6 
7 use GuzzleHttp\Client;
8 
10 {
11  public function createTokenStorageProvider(
12  string $anonTokenUrl,
13  string $refreshTokenUrl,
14  ClientCredentials $credentials,
15  Client $client,
16  TokenStorage $storage,
17  AnonymousIdProvider $anonymousIdProvider = null
19  $refreshTokenProvider = $this->createRefreshFlowProvider($refreshTokenUrl, $credentials, $client, $storage);
20  $anonProvider = $this->createAnonymousFlowProvider(
21  $anonTokenUrl,
22  $credentials,
23  $client,
24  $refreshTokenProvider,
25  $anonymousIdProvider
26  );
27 
28  return new TokenStorageProvider($storage, $anonProvider);
29  }
30 
31  public function createPasswordFlowProvider(
32  string $passwordTokenUrl,
33  ClientCredentials $credentials,
34  Client $client,
35  TokenStorage $storage
37  return new PasswordFlowTokenProvider($client, $passwordTokenUrl, $credentials, $storage);
38  }
39 
40  public function createAnonymousFlowProvider(
41  string $anonTokenUrl,
42  ClientCredentials $credentials,
43  Client $client,
44  RefreshFlowTokenProvider $refreshFlowTokenProvider,
45  AnonymousIdProvider $anonymousIdProvider = null
47  return new AnonymousFlowTokenProvider(
48  $client,
49  $anonTokenUrl,
50  $credentials,
51  $refreshFlowTokenProvider,
52  $anonymousIdProvider
53  );
54  }
55 
56  public function createRefreshFlowProvider(
57  string $refreshTokenUrl,
58  ClientCredentials $credentials,
59  Client $client,
60  TokenStorage $storage
62  return new RefreshFlowTokenProvider($client, $refreshTokenUrl, $credentials, $storage);
63  }
64 
65  public static function of(): ProviderFactory
66  {
67  return new self();
68  }
69 }
createRefreshFlowProvider(string $refreshTokenUrl, ClientCredentials $credentials, Client $client, TokenStorage $storage)
createTokenStorageProvider(string $anonTokenUrl, string $refreshTokenUrl, ClientCredentials $credentials, Client $client, TokenStorage $storage, AnonymousIdProvider $anonymousIdProvider=null)
createPasswordFlowProvider(string $passwordTokenUrl, ClientCredentials $credentials, Client $client, TokenStorage $storage)
createAnonymousFlowProvider(string $anonTokenUrl, ClientCredentials $credentials, Client $client, RefreshFlowTokenProvider $refreshFlowTokenProvider, AnonymousIdProvider $anonymousIdProvider=null)