1 | <?php |
||||
2 | |||||
3 | namespace Signifly\Shopify; |
||||
4 | |||||
5 | use Illuminate\Contracts\Foundation\Application; |
||||
6 | use Illuminate\Support\Facades\Request; |
||||
7 | use Illuminate\Support\Facades\Route; |
||||
8 | use Illuminate\Support\ServiceProvider; |
||||
9 | use Signifly\Shopify\Exceptions\ErrorHandlerInterface; |
||||
10 | use Signifly\Shopify\Exceptions\Handler; |
||||
11 | use Signifly\Shopify\Http\Controllers\WebhookController; |
||||
12 | use Signifly\Shopify\Webhooks\SecretProvider; |
||||
13 | use Signifly\Shopify\Webhooks\Webhook; |
||||
14 | |||||
15 | class ShopifyServiceProvider extends ServiceProvider |
||||
16 | { |
||||
17 | public function boot() |
||||
18 | { |
||||
19 | $this->publishConfig(); |
||||
20 | $this->registerMacros(); |
||||
21 | } |
||||
22 | |||||
23 | public function register() |
||||
24 | { |
||||
25 | $this->app->singleton(Shopify::class, fn () => Factory::fromConfig()); |
||||
26 | |||||
27 | $this->app->alias(Shopify::class, 'shopify'); |
||||
28 | |||||
29 | $this->app->bind(ErrorHandlerInterface::class, Handler::class); |
||||
30 | |||||
31 | $this->app->singleton(SecretProvider::class, function (Application $app) { |
||||
32 | $secretProvider = config('shopify.webhooks.secret_provider'); |
||||
33 | |||||
34 | return $app->make($secretProvider); |
||||
35 | }); |
||||
36 | } |
||||
37 | |||||
38 | protected function publishConfig() |
||||
39 | { |
||||
40 | if ($this->app->runningInConsole()) { |
||||
41 | $this->publishes([ |
||||
42 | __DIR__.'/../config/shopify.php' => config_path('shopify.php'), |
||||
43 | ], 'laravel-shopify'); |
||||
44 | } |
||||
45 | |||||
46 | $this->mergeConfigFrom(__DIR__.'/../config/shopify.php', 'shopify'); |
||||
47 | } |
||||
48 | |||||
49 | protected function registerMacros(): void |
||||
50 | { |
||||
51 | Route::macro('shopifyWebhooks', function (string $uri = 'shopify/webhooks') { |
||||
52 | return $this->post($uri, [WebhookController::class, 'handle'])->name('shopify.webhooks'); |
||||
0 ignored issues
–
show
|
|||||
53 | }); |
||||
54 | |||||
55 | Request::macro('shopifyShopDomain', fn () => $this->header(Webhook::HEADER_SHOP_DOMAIN)); |
||||
0 ignored issues
–
show
The method
header() does not exist on Signifly\Shopify\ShopifyServiceProvider .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
56 | |||||
57 | Request::macro('shopifyHmacSignature', fn () => $this->header(Webhook::HEADER_HMAC_SIGNATURE)); |
||||
58 | |||||
59 | Request::macro('shopifyTopic', fn () => $this->header(Webhook::HEADER_TOPIC)); |
||||
60 | } |
||||
61 | } |
||||
62 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.