function mailchimp_campaign_entity_storage_load in Mailchimp 8
Same name and namespace in other branches
- 2.x modules/mailchimp_campaign/mailchimp_campaign.module \mailchimp_campaign_entity_storage_load()
Implements hook_entity_storage_load().
File
- modules/
mailchimp_campaign/ mailchimp_campaign.module, line 15 - Module file for mailchimp_campaign.
Code
function mailchimp_campaign_entity_storage_load(array $entities, $entity_type) {
if ($entity_type != 'mailchimp_campaign') {
return;
}
$ids = [];
if (!empty($entities)) {
/* @var $campaign \Drupal\mailchimp_campaign\Entity\MailchimpCampaign */
foreach ($entities as $campaign) {
$ids[] = $campaign
->getMcCampaignId();
}
}
$mc_campaigns = mailchimp_campaign_get_campaigns($ids);
foreach ($entities as $mc_campaign_id => $campaign) {
// Ensure the associated list still exists.
if (!isset($mc_campaigns[$mc_campaign_id]) || !$mc_campaigns[$mc_campaign_id]) {
continue;
}
$campaign->mc_data = $mc_campaigns[$mc_campaign_id];
// Lists are cached separately, but we want to load them here.
if (isset($campaign->mc_data->recipients->list_id) && $campaign->mc_data->recipients->list_id) {
$campaign->list = mailchimp_get_list($campaign->mc_data->recipients->list_id);
}
if (isset($campaign->mc_data->settings->template_id) && $campaign->mc_data->settings->template_id) {
$campaign->mc_template = mailchimp_campaign_get_template($campaign->mc_data->settings->template_id);
}
}
}