diff --git a/app/bundles/PluginBundle/EventListener/PushToIntegrationTrait.php b/app/bundles/PluginBundle/EventListener/PushToIntegrationTrait.php index a1368e17084..65762029233 100644 --- a/app/bundles/PluginBundle/EventListener/PushToIntegrationTrait.php +++ b/app/bundles/PluginBundle/EventListener/PushToIntegrationTrait.php @@ -44,22 +44,20 @@ protected function pushToIntegration(array $config, Lead $lead, array &$errors = } /** - * Used because the the Point trigger actions have not be converted to Events yet and thus must leverage a callback. + * Used because the Point trigger actions have not been converted to Events yet and thus must leverage a callback. * - * @param $config - * @param $lead - * @param $errors + * @param array|null> $config + * @param Lead $lead + * @param mixed[] $errors * * @return bool */ protected static function pushIt($config, $lead, &$errors) { - $integration = (!empty($config['integration'])) ? $config['integration'] : null; - $integrationCampaign = (!empty($config['config']['campaigns'])) ? $config['config']['campaigns'] : null; - $integrationMemberStatus = (!empty($config['campaign_member_status']['campaign_member_status'])) - ? $config['campaign_member_status']['campaign_member_status'] : null; - $services = static::$integrationHelper->getIntegrationObjects($integration); - $success = true; + $integration = (!empty($config['integration'])) ? $config['integration'] : null; + $integrationCampaign = (!empty($config['config']['campaigns'])) ? $config['config']['campaigns'] : null; + $services = static::$integrationHelper->getIntegrationObjects($integration); + $success = true; /** * @var string @@ -82,7 +80,7 @@ protected static function pushIt($config, $lead, &$errors) } if ($success && $integrationCampaign && method_exists($s, 'pushLeadToCampaign')) { - if (!$s->resetLastIntegrationError()->pushLeadToCampaign($lead, $integrationCampaign, $integrationMemberStatus, $personIds)) { + if (!$s->resetLastIntegrationError()->pushLeadToCampaign($lead, $integrationCampaign, $personIds, $config)) { $success = false; if ($error = $s->getLastIntegrationError()) { $errors[] = $error; diff --git a/app/bundles/PluginBundle/Integration/AbstractIntegration.php b/app/bundles/PluginBundle/Integration/AbstractIntegration.php index a055ec6e493..bce82230481 100644 --- a/app/bundles/PluginBundle/Integration/AbstractIntegration.php +++ b/app/bundles/PluginBundle/Integration/AbstractIntegration.php @@ -49,7 +49,7 @@ /** * @method pushLead(Lead $lead, array $config = []) - * @method pushLeadToCampaign(Lead $lead, mixed $integrationCampaign, mixed $integrationMemberStatus) + * @method pushLeadToCampaign(Lead $lead, mixed $integrationCampaignId, mixed $personIds = null, array $config = []) * @method getLeads(array $params, string $query, &$executed, array $result = [], $object = 'Lead') * @method getCompanies(array $params) * diff --git a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php index 11e2c6c1966..6ae77a0b0c5 100644 --- a/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php +++ b/plugins/MauticCrmBundle/Integration/SalesforceIntegration.php @@ -1504,12 +1504,13 @@ public function getCampaignMemberStatus($campaignId) } /** - * @param $campaignId - * @param $status + * @param string|int $integrationCampaignId + * @param array|null>|null $personIds + * @param array|null> $config * * @return array */ - public function pushLeadToCampaign(Lead $lead, $campaignId, $status = '', $personIds = null) + public function pushLeadToCampaign(Lead $lead, $integrationCampaignId, $personIds = null, array $config = []) { if (empty($personIds)) { // personIds should have been generated by pushLead() @@ -1518,13 +1519,12 @@ public function pushLeadToCampaign(Lead $lead, $campaignId, $status = '', $perso } $mauticData = []; - $objectId = null; /** @var IntegrationEntityRepository $integrationEntityRepo */ $integrationEntityRepo = $this->em->getRepository('MauticPluginBundle:IntegrationEntity'); $body = [ - 'Status' => $status, + 'Status' => (!empty($config['campaign_member_status']['campaign_member_status'])) ? $config['campaign_member_status']['campaign_member_status'] : null, ]; $object = 'CampaignMember'; $url = '/services/data/v38.0/sobjects/'.$object; @@ -1536,19 +1536,19 @@ public function pushLeadToCampaign(Lead $lead, $campaignId, $status = '', $perso // Give precendence to Contact CampaignMembers if (!empty($personIds['Contact'])) { $pushObject = 'Contact'; - $campaignMembers = $this->getApiHelper()->checkCampaignMembership($campaignId, $pushObject, $personIds[$pushObject]); + $campaignMembers = $this->getApiHelper()->checkCampaignMembership($integrationCampaignId, $pushObject, $personIds[$pushObject]); $pushPeople = $personIds[$pushObject]; } if (empty($campaignMembers) && !empty($personIds['Lead'])) { $pushObject = 'Lead'; - $campaignMembers = $this->getApiHelper()->checkCampaignMembership($campaignId, $pushObject, $personIds[$pushObject]); + $campaignMembers = $this->getApiHelper()->checkCampaignMembership($integrationCampaignId, $pushObject, $personIds[$pushObject]); $pushPeople = $personIds[$pushObject]; } } // pushLead should have handled this foreach ($pushPeople as $memberId) { - $campaignMappingId = '-'.$campaignId; + $campaignMappingId = '-'.$integrationCampaignId; if (isset($campaignMembers[$memberId])) { $existingCampaignMember = $integrationEntityRepo->getIntegrationsEntityId( @@ -1593,7 +1593,7 @@ public function pushLeadToCampaign(Lead $lead, $campaignId, $status = '', $perso 'body' => array_merge( $body, [ - 'CampaignId' => $campaignId, + 'CampaignId' => $integrationCampaignId, "{$pushObject}Id" => $memberId, ] ), diff --git a/plugins/MauticCrmBundle/Tests/Integration/SalesforceIntegrationTest.php b/plugins/MauticCrmBundle/Tests/Integration/SalesforceIntegrationTest.php index 480065c8b98..2fa0afc538b 100644 --- a/plugins/MauticCrmBundle/Tests/Integration/SalesforceIntegrationTest.php +++ b/plugins/MauticCrmBundle/Tests/Integration/SalesforceIntegrationTest.php @@ -455,7 +455,7 @@ function () { } ); - $sf->pushLeadToCampaign($lead, 1, 'Active', ['Lead' => [1]]); + $sf->pushLeadToCampaign($lead, 1, ['Lead' => [1]]); } public function testPushCompany()