Skip to content

Commit 6129c6f

Browse files
committed
Craft 4 compatibility
1 parent 1c3ad30 commit 6129c6f

File tree

9 files changed

+584
-629
lines changed

9 files changed

+584
-629
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
"docs": "https://github.com/craftcms/webhooks/blob/master/README.md",
2525
"rss": "https://github.com/craftcms/webhooks/commits/master.atom"
2626
},
27+
"minimum-stability": "dev",
2728
"require": {
28-
"craftcms/cms": "^3.7.0"
29+
"craftcms/cms": "^4.0.0-alpha"
2930
},
3031
"require-dev": {
3132
"phpstan/phpstan": "^0.12.96"

composer.lock

Lines changed: 566 additions & 613 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Plugin.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace craft\webhooks;
44

55
use Craft;
6+
use craft\base\Model;
67
use craft\db\Query;
78
use craft\events\RegisterComponentTypesEvent;
89
use craft\events\RegisterUrlRulesEvent;
@@ -81,17 +82,17 @@ class Plugin extends \craft\base\Plugin
8182
/**
8283
* @inheritdoc
8384
*/
84-
public $hasCpSettings = true;
85+
public bool $hasCpSettings = true;
8586

8687
/**
8788
* @inheritdoc
8889
*/
89-
public $hasCpSection = true;
90+
public bool $hasCpSection = true;
9091

9192
/**
9293
* @inheritdoc
9394
*/
94-
public $schemaVersion = '2.4.0';
95+
public string $schemaVersion = '2.4.0';
9596

9697
/**
9798
* @var SendRequestJob[] The request jobs that should be queued up at the end of the web request.
@@ -252,7 +253,7 @@ function(RegisterUrlRulesEvent $e) {
252253
/**
253254
* @inheritdoc
254255
*/
255-
protected function settingsHtml()
256+
protected function settingsHtml(): ?string
256257
{
257258
return Craft::$app->getView()->renderTemplate('webhooks/_settings', [
258259
'settings' => $this->getSettings(),
@@ -262,7 +263,7 @@ protected function settingsHtml()
262263
/**
263264
* @inheritdoc
264265
*/
265-
public function getCpNavItem()
266+
public function getCpNavItem(): ?array
266267
{
267268
$item = parent::getCpNavItem();
268269
$item['subnav'] = [
@@ -494,7 +495,7 @@ public function getWebhookManager(): WebhookManager
494495
/**
495496
* @inheritdoc
496497
*/
497-
protected function createSettingsModel()
498+
protected function createSettingsModel(): ?Model
498499
{
499500
return new Settings();
500501
}

src/SendRequestJob.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SendRequestJob extends BaseJob
2828
/**
2929
* @inheritdoc
3030
*/
31-
public function defaultDescription()
31+
public function defaultDescription(): ?string
3232
{
3333
if ($webhook = $this->_webhook()) {
3434
$description = Craft::t('webhooks', 'Sending webhook “{name}”', [
@@ -48,7 +48,7 @@ public function defaultDescription()
4848
/**
4949
* @inheritdoc
5050
*/
51-
public function execute($queue)
51+
public function execute($queue): void
5252
{
5353
$success = Plugin::getInstance()->sendRequest($this->requestId);
5454

src/Settings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Settings extends Model
4646
/**
4747
* @inheritdoc
4848
*/
49-
public function setAttributes($values, $safeOnly = true)
49+
public function setAttributes($values, $safeOnly = true): void
5050
{
5151
// attemptDelay → retryDelay
5252
if (($retryDelay = ArrayHelper::remove($values, 'attemptDelay')) !== null) {
@@ -80,7 +80,7 @@ protected function defineRules(): array
8080
/**
8181
* @inheritdoc
8282
*/
83-
public function fields()
83+
public function fields(): array
8484
{
8585
$fields = parent::fields();
8686
// guzzleConfig can't be set from the UI so no point in storing it in the project config
@@ -91,7 +91,7 @@ public function fields()
9191
/**
9292
* @inheritdoc
9393
*/
94-
public function extraFields()
94+
public function extraFields(): array
9595
{
9696
return [
9797
'guzzleConfig',

src/assets/activity/ActivityAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace craft\webhooks\assets\activity;
99

10-
use craft\web\AssetBundle;
1110
use craft\web\assets\cp\CpAsset;
11+
use yii\web\AssetBundle;
1212

1313
/**
1414
* Webhooks index asset bundle

src/assets/edit/EditAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
namespace craft\webhooks\assets\edit;
99

10-
use craft\web\AssetBundle;
1110
use craft\web\assets\cp\CpAsset;
11+
use yii\web\AssetBundle;
1212

1313
/**
1414
* Webhooks index asset bundle

src/assets/manage/ManageAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
namespace craft\webhooks\assets\manage;
99

10-
use craft\web\AssetBundle;
1110
use craft\web\assets\cp\CpAsset;
1211
use craft\web\View;
12+
use yii\web\AssetBundle;
1313

1414
/**
1515
* Webhooks index asset bundle

src/controllers/BaseController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class BaseController extends Controller
1515
/**
1616
* @inheritdoc
1717
*/
18-
public function beforeAction($action)
18+
public function beforeAction($action): bool
1919
{
2020
if (!parent::beforeAction($action)) {
2121
return false;

0 commit comments

Comments
 (0)