Skip to content

Commit 05775bb

Browse files
committed
Merge branch 'develop' of https://github.com/craftcms/webhooks into 3.0
2 parents 6129c6f + 906f8e3 commit 05775bb

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes for Webhooks for Craft CMS
22

3+
## 2.4.1 - 2021-09-09
4+
5+
### Added
6+
- Added the `disableAllWebhooks` setting. ([#4](https://github.com/craftcms/webhooks/issues/4))
7+
38
## 2.4.0.1 - 2021-08-30
49

510
### Fixed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ To configure Webhooks, go to **Settings** → **Webhooks**, or create a `config/
4040
```php
4141
<?php
4242
return [
43+
'disableAllWebhooks' => false,
4344
'maxDepth' => 10,
4445
'maxAttempts' => 3,
4546
'initialDelay' => null,
@@ -50,6 +51,7 @@ return [
5051

5152
The array can define the following keys:
5253

54+
- `disableAllWebhooks` – Whether all webhooks should be disabled.
5355
- `maxDepth` – The maximum depth that the plugin should go into objects/arrays when converting them to arrays for event payloads. (Default is `5`.)
5456
- `maxAttempts` – The maximum number of attempts each webhook should have before giving up, if the requests are coming back with non 2xx responses. (Default is `1`.)
5557
- `initialDelay` – The delay (in seconds) that initial webhook request attempts should have.
@@ -200,6 +202,15 @@ Webhooks can be enabled or disabled from both the Webhooks index page and within
200202

201203
Only enabled webhooks will send webhook requests when their corresponding events are triggered.
202204

205+
You can disable *all* webhooks by setting `disableAllWebhooks` to `true` in your `config/webhooks.php` file.
206+
207+
```php
208+
return [
209+
'disableAllWebhooks' => true,
210+
// ...
211+
];
212+
```
213+
203214
## Integrating with Task Automation Tools
204215

205216
### Netlify

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "craftcms/webhooks",
33
"description": "Post webhooks when events are triggered in Craft CMS.",
4-
"version": "2.4.0.1",
4+
"version": "2.4.1",
55
"type": "craft-plugin",
66
"keywords": [
77
"html",

src/Plugin.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,14 @@ public function init()
117117
$this->set('webhookManager', $manager);
118118

119119
// Register webhook events
120-
try {
121-
$webhooks = $manager->getEnabledWebhooks();
122-
} catch (Throwable $e) {
123-
Craft::error('Unable to fetch enabled webhooks: ' . $e->getMessage(), __METHOD__);
124-
Craft::$app->getErrorHandler()->logException($e);
125-
$webhooks = [];
120+
$webhooks = [];
121+
if (!$this->getSettings()->disableAllWebhooks) {
122+
try {
123+
$webhooks = $manager->getEnabledWebhooks();
124+
} catch (Throwable $e) {
125+
Craft::error('Unable to fetch enabled webhooks: ' . $e->getMessage(), __METHOD__);
126+
Craft::$app->getErrorHandler()->logException($e);
127+
}
126128
}
127129

128130
foreach ($webhooks as $webhook) {

src/Settings.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77

88
class Settings extends Model
99
{
10+
/**
11+
* @var bool Whether all webhooks should be disabled.
12+
* @since 2.4.1
13+
*/
14+
public $disableAllWebhooks = false;
15+
1016
/**
1117
* @var int The maximum depth that the plugin should go into objects/arrays when converting them to arrays for
1218
* event payloads.

src/templates/_manage/index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
</tbody>
6060
</table>
6161
{% else %}
62-
<p>{{ 'No webhooks exist yet.'|t('webhooks') }}</p>
62+
<div class="zilch">
63+
<p>{{ 'No webhooks exist yet.'|t('webhooks') }}</p>
64+
</div>
6365
{% endif %}
6466
{% endblock %}

0 commit comments

Comments
 (0)