Skip to content

Commit f8d7e7c

Browse files
committed
Try and catch the theme support and any error we keep the theme null
1 parent b3047a4 commit f8d7e7c

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Actions/InstallShop.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Osiset\ShopifyApp\Objects\Values\NullAccessToken;
1111
use Osiset\ShopifyApp\Objects\Values\ShopDomain;
1212
use Osiset\ShopifyApp\Objects\Values\ThemeSupportLevel;
13+
use Osiset\ShopifyApp\Objects\Enums\ThemeSupportLevel as ThemeSupportLevelEnum;
1314
use Osiset\ShopifyApp\Util;
1415

1516
/**
@@ -100,8 +101,15 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): array
100101
$data = $apiHelper->getAccessData($code);
101102
$this->shopCommand->setAccessToken($shop->getId(), AccessToken::fromNative($data['access_token']));
102103

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+
105113

106114
return [
107115
'completed' => true,

src/Objects/Enums/ThemeSupportLevel.php

+7
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,11 @@ class ThemeSupportLevel implements ValueObject
3232
* @var int
3333
*/
3434
public const UNSUPPORTED = 2;
35+
36+
/**
37+
* Support level: None.
38+
*
39+
* @var null
40+
*/
41+
public const NONE = null;
3542
}

0 commit comments

Comments
 (0)