Skip to content

Instantly share code, notes, and snippets.

@ssddanbrown
Created January 6, 2022 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssddanbrown/5e62dbbb96b6f239da3355c47772abd6 to your computer and use it in GitHub Desktop.
Save ssddanbrown/5e62dbbb96b6f239da3355c47772abd6 to your computer and use it in GitHub Desktop.
BookStack Webhook Call Before Hook Example
<?php
use BookStack\Actions\Webhook;
use BookStack\Entities\Models\Page;
use BookStack\Facades\Theme;
use BookStack\Theming\ThemeEvents;
Theme::listen(ThemeEvents::WEBHOOK_CALL_BEFORE, function (string $event, Webhook $webhook, $detail) {
// Add a condition to only run this custom logic for specific webhook calls.
if ($webhook->name === 'Debug Webhook') {
// Build and return the data which will be sent as JSON to the endpoint.
$webhookData = [
'the_event' => $event,
];
if ($detail instanceof Page) {
$webhookData['text'] = 'The page updated was named: ' . $detail->name;
}
return $webhookData;
}
return null;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment