File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ return [
4+ /*
5+ |--------------------------------------------------------------------------
6+ | Disable Calls
7+ |--------------------------------------------------------------------------
8+ |
9+ | When set to true, no webhooks will be called
10+ |
11+ */
12+
13+ "disable_webhooks " => env ('ZAPIER_DISABLE_WEBHOOKS ' , false ),
14+
15+ /*
16+ |--------------------------------------------------------------------------
17+ | Force URL
18+ |--------------------------------------------------------------------------
19+ |
20+ | When set, all zapier webhooks will use this URL. This can be used to
21+ | redirect all calls in a dev environment to a single test URL.
22+ |
23+ */
24+
25+ "force_url " => env ('ZAPIER_FORCE_URL ' , null ),
26+
27+ ];
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function edit()
3333
3434 public function update (Request $ request )
3535 {
36- abort_unless (User::current ()->can ('configure form zapier webshooks ' ), 403 );
36+ abort_unless (User::current ()->can ('configure form zapier webhooks ' ), 403 );
3737
3838 $ blueprint = Webhooks::blueprint ();
3939
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ public function handle(FormSubmitted $event)
2020 {
2121 $ webhooks = Webhooks::byForm ($ event ->submission ->form ->handle ());
2222
23- if (is_null ($ webhooks )) return ;
23+ if (is_null ($ webhooks ) || config ( ' statamic.zapier.disable_webhooks ' ) ) return ;
2424
2525 foreach ($ webhooks as $ webhook ) {
2626 $ this ->sendToWebhook ($ webhook ['webhook ' ], $ event );
@@ -32,6 +32,10 @@ public function handle(FormSubmitted $event)
3232 */
3333 private function sendToWebhook ($ webhookUrl , FormSubmitted $ event )
3434 {
35+
36+ // Overwrite webhook url with force url if set in config
37+ $ webhookUrl = config ('statamic.zapier.force_url ' ) ?? $ webhookUrl ;
38+
3539 // all data
3640 $ data = $ event ->submission ->data ();
3741 $ data ['submission_id ' ] = $ event ->submission ->id ();
Original file line number Diff line number Diff line change @@ -23,7 +23,10 @@ public function boot()
2323 {
2424 parent ::boot ();
2525
26- // // load views
26+ // load publishables
27+ $ this ->bootPublishables ();
28+
29+ // load views
2730 $ this ->loadViewsFrom (__DIR__ . '/../resources/views/ ' , 'statamic-zapier ' );
2831
2932 // load navigation
@@ -35,6 +38,17 @@ public function boot()
3538 });
3639 }
3740
41+ public function bootPublishables (): static
42+ {
43+ if ($ this ->app ->runningInConsole ()) {
44+ $ this ->publishes ([
45+ __DIR__ .'/../config/statamic/zapier.php ' => config_path ('/statamic/zapier.php ' ),
46+ ], 'config ' );
47+ }
48+
49+ return $ this ;
50+ }
51+
3852 private function bootNavigation (): void
3953 {
4054 Nav::extend (function ($ nav ) {
You can’t perform that action at this time.
0 commit comments