diff --git a/src/ApiKeyFinder/CurrentApiKeyFinder.php b/src/ApiKeyFinder/CurrentApiKeyFinder.php new file mode 100644 index 00000000..cdab7f6e --- /dev/null +++ b/src/ApiKeyFinder/CurrentApiKeyFinder.php @@ -0,0 +1,34 @@ +toNative() : $shop; + $shopDomain = explode('.', $shopDomain)[0]; + $searchKey = "shopify-app.config_api_shop_keys.{$key}_{$shopDomain}"; + + if (! Config::has($searchKey)) { + return Config::get($fullKey); + } + + return Config::get($searchKey); + } +} \ No newline at end of file diff --git a/src/Contracts/CurrentApiKeyFinderInterface.php b/src/Contracts/CurrentApiKeyFinderInterface.php new file mode 100644 index 00000000..e43df18e --- /dev/null +++ b/src/Contracts/CurrentApiKeyFinderInterface.php @@ -0,0 +1,8 @@ + env('SCRIPTTAGS_JOB_CONNECTION', null), 'after_authenticate' => env('AFTER_AUTHENTICATE_JOB_CONNECTION', null), ], + /* |-------------------------------------------------------------------------- | Config API Callback @@ -487,11 +488,37 @@ | A closure/callable is required. | The first argument will be the key string. | The second argument will be something to help identify the shop. + | + | This will break caching config values because Closures can not be serialized. + | Use config_api_class below instead. | */ 'config_api_callback' => null, + /* + |-------------------------------------------------------------------------- + | Config API Resolver Class + |-------------------------------------------------------------------------- + | + | This option can be used to modify what returns when `getConfig('api_*')` + | is used. A use-case for this is modifying the return of `api_secret` + | or something similar. + | + | A class name is required + | The class must implement Osiset\ShopifyApp\Contracts\CurrentApiKeyFinderInterface + | A default class is provided and can be uncommented below. + | + | config_api_callback will take priority for backwards-compatibility however, + | this option is the recommended way because closures can not be serialized. + | + */ + + // 'config_api_class' => Osiset\ShopifyApp\ApiKeyFinder\CurrentApiKeyFinder::class, + // 'config_api_shop_keys' => [ + // 'api_key_shop-name' => env('API_KEY_SHOPNAME', ''), + // ], + /* |-------------------------------------------------------------------------- | Customize Models and Table Name