From 5b55002d35b429a572a9bd686ccb8b05c07856d6 Mon Sep 17 00:00:00 2001 From: bencroker Date: Thu, 8 Jun 2023 20:13:09 +0200 Subject: [PATCH] Register Feed Me elements for all request types --- CHANGELOG.md | 4 ++++ composer.json | 2 +- src/Campaign.php | 33 +++++++++++++++++++-------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac016a22..b211dc3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Campaign +## 2.8.1 - 2023-06-08 +### Fixed +Fixed a bug in which Feed Me imports were not working when the queue was being run via console requests ([#395](https://github.com/putyourlightson/craft-campaign/issues/395)). + ## 2.8.0 - 2023-06-01 ### Added - Added the ability to import campaigns, contacts and mailing lists using Feed Me ([#395](https://github.com/putyourlightson/craft-campaign/issues/395)). diff --git a/composer.json b/composer.json index ed3fa327..2b08b69d 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "putyourlightson/craft-campaign", "description": "Send and manage email campaigns, contacts and mailing lists.", - "version": "2.8.0", + "version": "2.8.1", "type": "craft-plugin", "homepage": "https://putyourlightson.com/plugins/campaign", "license": "proprietary", diff --git a/src/Campaign.php b/src/Campaign.php index dc1ed01a..41249826 100644 --- a/src/Campaign.php +++ b/src/Campaign.php @@ -205,6 +205,7 @@ public function init(): void $this->_registerTemplateHooks(); $this->_registerAllowedOrigins(); $this->_registerTwigExtensions(); + $this->_registerFeedMeElements(); // Register tracker controller shorthand for site requests if (Craft::$app->getRequest()->getIsSiteRequest()) { @@ -217,7 +218,6 @@ public function init(): void $this->_registerCpUrlRules(); $this->_registerUtilities(); $this->_registerWidgets(); - $this->_registerFeedMeElements(); } // If Craft edition is pro @@ -694,6 +694,24 @@ private function _registerTwigExtensions(): void Craft::$app->getView()->registerTwigExtension(new CampaignTwigExtension()); } + /** + * Registers Feed Me elements. + * + * @since 2.8.0 + */ + private function _registerFeedMeElements(): void + { + if (Craft::$app->getPlugins()->isPluginInstalled('feed-me')) { + Event::on(FeedMeElements::class, FeedMeElements::EVENT_REGISTER_FEED_ME_ELEMENTS, + function(RegisterFeedMeElementsEvent $event) { + $event->elements[] = CampaignFeedMeElement::class; + $event->elements[] = ContactFeedMeElement::class; + $event->elements[] = MailingListFeedMeElement::class; + } + ); + } + } + /** * Registers native fields. * @@ -845,17 +863,4 @@ function(RegisterUserPermissionsEvent $event) { } ); } - - private function _registerFeedMeElements(): void - { - if (Craft::$app->getPlugins()->isPluginInstalled('feed-me')) { - Event::on(FeedMeElements::class, FeedMeElements::EVENT_REGISTER_FEED_ME_ELEMENTS, - function(RegisterFeedMeElementsEvent $event) { - $event->elements[] = CampaignFeedMeElement::class; - $event->elements[] = ContactFeedMeElement::class; - $event->elements[] = MailingListFeedMeElement::class; - } - ); - } - } }