Skip to content

Commit

Permalink
Register Feed Me elements for all request types
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Jun 8, 2023
1 parent 58597d6 commit 5b55002
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
33 changes: 19 additions & 14 deletions src/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -217,7 +218,6 @@ public function init(): void
$this->_registerCpUrlRules();
$this->_registerUtilities();
$this->_registerWidgets();
$this->_registerFeedMeElements();
}

// If Craft edition is pro
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
);
}
}
}

0 comments on commit 5b55002

Please sign in to comment.