9
9
use Osiset \ShopifyApp \Objects \Values \AccessToken ;
10
10
use Osiset \ShopifyApp \Objects \Values \NullAccessToken ;
11
11
use Osiset \ShopifyApp \Objects \Values \ShopDomain ;
12
+ use Osiset \ShopifyApp \Objects \Values \ThemeSupportLevel ;
12
13
use Osiset \ShopifyApp \Util ;
13
14
14
15
/**
@@ -30,19 +31,29 @@ class InstallShop
30
31
*/
31
32
protected $ shopCommand ;
32
33
34
+ /**
35
+ * The action for verify theme support
36
+ *
37
+ * @var VerifyThemeSupport
38
+ */
39
+ protected $ verifyThemeSupport ;
40
+
33
41
/**
34
42
* Setup.
35
43
*
36
44
* @param IShopQuery $shopQuery The querier for the shop.
45
+ * @param VerifyThemeSupport $verifyThemeSupport The action for verify theme support
37
46
*
38
47
* @return void
39
48
*/
40
49
public function __construct (
41
50
IShopQuery $ shopQuery ,
42
- IShopCommand $ shopCommand
51
+ IShopCommand $ shopCommand ,
52
+ VerifyThemeSupport $ verifyThemeSupport
43
53
) {
44
54
$ this ->shopQuery = $ shopQuery ;
45
55
$ this ->shopCommand = $ shopCommand ;
56
+ $ this ->verifyThemeSupport = $ verifyThemeSupport ;
46
57
}
47
58
48
59
/**
@@ -57,6 +68,7 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): array
57
68
{
58
69
// Get the shop
59
70
$ shop = $ this ->shopQuery ->getByDomain ($ shopDomain , [], true );
71
+
60
72
if ($ shop === null ) {
61
73
// Shop does not exist, make them and re-get
62
74
$ this ->shopCommand ->make ($ shopDomain , NullAccessToken::fromNative (null ));
@@ -88,17 +100,22 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): array
88
100
$ data = $ apiHelper ->getAccessData ($ code );
89
101
$ this ->shopCommand ->setAccessToken ($ shop ->getId (), AccessToken::fromNative ($ data ['access_token ' ]));
90
102
103
+ $ themeSupportLevel = call_user_func ($ this ->verifyThemeSupport , $ shop ->getId ());
104
+ $ this ->shopCommand ->setThemeSupportLevel ($ shop ->getId (), ThemeSupportLevel::fromNative ($ themeSupportLevel ));
105
+
91
106
return [
92
107
'completed ' => true ,
93
108
'url ' => null ,
94
109
'shop_id ' => $ shop ->getId (),
110
+ 'theme_support_level ' => $ themeSupportLevel ,
95
111
];
96
112
} catch (Exception $ e ) {
97
113
// Just return the default setting
98
114
return [
99
115
'completed ' => false ,
100
116
'url ' => null ,
101
117
'shop_id ' => null ,
118
+ 'theme_support_level ' => null ,
102
119
];
103
120
}
104
121
}
0 commit comments