6
6
use Osiset \ShopifyApp \Contracts \Commands \Shop as IShopCommand ;
7
7
use Osiset \ShopifyApp \Contracts \Queries \Shop as IShopQuery ;
8
8
use Osiset \ShopifyApp \Objects \Enums \AuthMode ;
9
+ use Osiset \ShopifyApp \Objects \Enums \ThemeSupportLevel as ThemeSupportLevelEnum ;
9
10
use Osiset \ShopifyApp \Objects \Values \AccessToken ;
10
11
use Osiset \ShopifyApp \Objects \Values \NullAccessToken ;
11
12
use Osiset \ShopifyApp \Objects \Values \ShopDomain ;
@@ -41,14 +42,14 @@ class InstallShop
41
42
/**
42
43
* Setup.
43
44
*
44
- * @param IShopQuery $shopQuery The querier for the shop.
45
- * @param VerifyThemeSupport $verifyThemeSupport The action for verify theme support
45
+ * @param IShopQuery $shopQuery The querier for the shop.
46
+ * @param VerifyThemeSupport $verifyThemeSupport The action for verify theme support
46
47
*
47
48
* @return void
48
49
*/
49
50
public function __construct (
50
- IShopQuery $ shopQuery ,
51
- IShopCommand $ shopCommand ,
51
+ IShopQuery $ shopQuery ,
52
+ IShopCommand $ shopCommand ,
52
53
VerifyThemeSupport $ verifyThemeSupport
53
54
) {
54
55
$ this ->shopQuery = $ shopQuery ;
@@ -59,8 +60,8 @@ public function __construct(
59
60
/**
60
61
* Execution.
61
62
*
62
- * @param ShopDomain $shopDomain The shop ID.
63
- * @param string|null $code The code from Shopify.
63
+ * @param ShopDomain $shopDomain The shop ID.
64
+ * @param string|null $code The code from Shopify.
64
65
*
65
66
* @return array
66
67
*/
@@ -100,8 +101,15 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): array
100
101
$ data = $ apiHelper ->getAccessData ($ code );
101
102
$ this ->shopCommand ->setAccessToken ($ shop ->getId (), AccessToken::fromNative ($ data ['access_token ' ]));
102
103
103
- $ themeSupportLevel = call_user_func ($ this ->verifyThemeSupport , $ shop ->getId ());
104
- $ this ->shopCommand ->setThemeSupportLevel ($ shop ->getId (), ThemeSupportLevel::fromNative ($ themeSupportLevel ));
104
+ // Try to get the theme support level, if not, return the default setting
105
+ try {
106
+ $ themeSupportLevel = call_user_func ($ this ->verifyThemeSupport , $ shop ->getId ());
107
+ $ this ->shopCommand ->setThemeSupportLevel ($ shop ->getId (), ThemeSupportLevel::fromNative ($ themeSupportLevel ));
108
+ } catch (Exception $ e ) {
109
+ // Just return the default setting which is null
110
+ $ themeSupportLevel = ThemeSupportLevelEnum::NONE ;
111
+ }
112
+
105
113
106
114
return [
107
115
'completed ' => true ,
0 commit comments