@@ -27,6 +27,18 @@ protected function getProvider(array $config): Provider
27
27
{
28
28
$ httplug = $ config ['httplug_client ' ] ?: $ this ->httpClient ?? HttpClientDiscovery::find ();
29
29
30
+ if (empty ($ config ['app_key ' ]) && empty ($ config ['app_id ' ]) && empty ($ config ['app_code ' ])) {
31
+ throw new \InvalidArgumentException ('No authentication key provided. Here requires app_key or app_code and app_id. ' );
32
+ }
33
+
34
+ if (!empty ($ config ['app_key ' ])) {
35
+ if (!method_exists (Here::class, 'createUsingApiKey ' )) {
36
+ throw new \InvalidArgumentException ('Here provider has no support for `creatingUsingApiKey` method. ' );
37
+ }
38
+
39
+ return Here::createUsingApiKey ($ httplug , $ config ['app_key ' ], $ config ['use_cit ' ]);
40
+ }
41
+
30
42
return new Here ($ httplug , $ config ['app_id ' ], $ config ['app_code ' ], $ config ['use_cit ' ]);
31
43
}
32
44
@@ -35,10 +47,15 @@ protected static function configureOptionResolver(OptionsResolver $resolver)
35
47
$ resolver ->setDefaults ([
36
48
'httplug_client ' => null ,
37
49
'use_cit ' => false ,
50
+ 'app_key ' => null ,
51
+ 'app_id ' => null ,
52
+ 'app_code ' => null ,
38
53
]);
39
54
40
55
$ resolver ->setAllowedTypes ('httplug_client ' , ['object ' , 'null ' ]);
56
+ $ resolver ->setAllowedTypes ('app_key ' , ['string ' , 'null ' ]);
57
+ $ resolver ->setAllowedTypes ('app_id ' , ['string ' , 'null ' ]);
58
+ $ resolver ->setAllowedTypes ('app_code ' , ['string ' , 'null ' ]);
41
59
$ resolver ->setAllowedTypes ('use_cit ' , ['bool ' , 'false ' ]);
42
- $ resolver ->setRequired (['app_id ' , 'app_code ' ]);
43
60
}
44
61
}
0 commit comments