From fa6b3d0c011232f74c9ffaffa428a5e5ac198d71 Mon Sep 17 00:00:00 2001 From: Tam Date: Thu, 7 Oct 2021 10:20:08 +0100 Subject: [PATCH] Fix compatibility issue with Gatsby Helper Fixes #20 --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/TagManager.php | 23 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99550a7..ef84d8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.9 - 2021-09-07 +### Fixed +- Fix compatibility issue with Gatsby Helper (Fixes #20) + ## 1.0.8 - 2021-09-04 ### Fixed - Fix tags not being listed on index (Fixes #18, via @stevecomrie) diff --git a/composer.json b/composer.json index 4c21a74..0592cc3 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "ether/tags", "description": "A tag manager for Craft 3", "type": "craft-plugin", - "version": "1.0.8", + "version": "1.0.9", "keywords": [ "craft", "cms", diff --git a/src/TagManager.php b/src/TagManager.php index ea5d23c..37faa05 100644 --- a/src/TagManager.php +++ b/src/TagManager.php @@ -10,11 +10,14 @@ use Craft; use craft\base\Element; +use craft\base\Model; use craft\base\Plugin; use craft\elements\actions\Edit; use craft\events\RegisterCpNavItemsEvent; use craft\events\RegisterElementActionsEvent; use craft\events\RegisterUrlRulesEvent; +use craft\gatsbyhelper\events\RegisterIgnoredTypesEvent; +use craft\gatsbyhelper\services\Deltas; use craft\web\twig\variables\Cp; use craft\web\UrlManager; use ether\tagManager\elements\actions\Delete; @@ -24,6 +27,7 @@ use Twig\Error\RuntimeError; use Twig\Error\SyntaxError; use yii\base\Event; +use yii\base\Exception; /** * Class Tags @@ -71,6 +75,14 @@ public function init () [$this, 'onRegisterCpNavItems'] ); + if (class_exists(Deltas::class)) { + Event::on( + Deltas::class, + Deltas::EVENT_REGISTER_IGNORED_TYPES, + [$this, 'onRegisterIgnoredTypes'] + ); + } + } // Craft @@ -86,13 +98,13 @@ public function getCpNavItem () return $item; } - protected function createSettingsModel () + protected function createSettingsModel (): Settings { return new Settings(); } /** - * @return bool|Settings|null + * @return bool|Model|null */ public function getSettings () { @@ -103,7 +115,7 @@ public function getSettings () * @return string|null * @throws LoaderError * @throws RuntimeError - * @throws SyntaxError + * @throws SyntaxError|Exception */ protected function settingsHtml () { @@ -162,4 +174,9 @@ public function onRegisterCpNavItems (RegisterCpNavItemsEvent $event) $event->navItems = $navItems; } + public function onRegisterIgnoredTypes (RegisterIgnoredTypesEvent $event) + { + $event->types[] = Tag::class; + } + } \ No newline at end of file