From 62524d9a856e50a121d959dce807261a6dc14188 Mon Sep 17 00:00:00 2001 From: Marcus Date: Wed, 4 Dec 2024 22:57:05 +0100 Subject: [PATCH] fix: support Craft 5.3+ --- composer.json | 2 +- src/helpers/TriggerHelper.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 169f5d8..2ae50a2 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "everyday/craft-incremental-static-regeneration", - "version": "1.3.0", + "version": "1.3.1", "description": "A plugin that watches your entry changes and pings a URL of your choice", "type": "craft-plugin", "keywords": ["incremental", "static", "regeneration", "nextjs"], diff --git a/src/helpers/TriggerHelper.php b/src/helpers/TriggerHelper.php index e578c23..2505f88 100644 --- a/src/helpers/TriggerHelper.php +++ b/src/helpers/TriggerHelper.php @@ -8,6 +8,7 @@ use craft\helpers\ElementHelper; use everyday\IncrementalStaticRegeneration\models\Settings; use yii\base\Event; +use yii\base\InvalidConfigException; class TriggerHelper { @@ -24,8 +25,14 @@ private static function getRelatedUris(Element $element, Settings $settings): ar private static function entryEntryTypeDisabled(Entry $entry, Settings $settings): bool { - foreach ($entry->section->entryTypes as $entryType) { - if (in_array($entryType->handle, $settings->excludedSections[$entry->section->handle] ?? [], + $section = $entry->getSection(); + + if(!$section) { + return true; + } + + foreach ($section->getEntryTypes() as $entryType) { + if (in_array($entryType->handle, $settings->excludedSections[$section->handle] ?? [], true)) { return true; } @@ -84,4 +91,4 @@ public static function globalSetAfterSaveTrigger(ModelEvent $event, Settings $se return self::getAllUris($settings); } -} \ No newline at end of file +}