Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed batch parameter from addLeadToCompany so that it doesn't deta… #2669

Merged
merged 1 commit into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions app/bundles/LeadBundle/Model/CompanyModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public function setFieldValues(Company &$company, array $data, $overwriteWithBla
*
* @throws \Doctrine\ORM\ORMException
*/
public function addLeadToCompany($companies, $lead, $manuallyAdded = false, $batchProcess = false, $searchCompanyLead = 1, $dateManipulated = null)
public function addLeadToCompany($companies, $lead, $manuallyAdded = false, $searchCompanyLead = 1, $dateManipulated = null)
{
// Primary company name to be peristed to the lead's contact company field
$companyName = '';
Expand Down Expand Up @@ -363,10 +363,7 @@ public function addLeadToCompany($companies, $lead, $manuallyAdded = false, $bat
}
}

if ($batchProcess) {
// Detach for batch processing to preserve memory
$this->em->detach($lead);
} elseif (!empty($dispatchEvents) && ($this->dispatcher->hasListeners(LeadEvents::LEAD_COMPANY_CHANGE))) {
if (!empty($dispatchEvents) && ($this->dispatcher->hasListeners(LeadEvents::LEAD_COMPANY_CHANGE))) {
foreach ($dispatchEvents as $companyId) {
$event = new LeadChangeCompanyEvent($lead, $companyLeadAdd[$companyId]);
$this->dispatcher->dispatch(LeadEvents::LEAD_COMPANY_CHANGE, $event);
Expand Down
4 changes: 2 additions & 2 deletions app/bundles/LeadBundle/Model/LeadModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,14 @@ public function saveEntity($entity, $unlock = true)
if ($leadAdded) {
$entity->addCompanyChangeLogEntry('form', 'Identify Company', 'Lead added to the company, '.$company['companyname'], $company['id']);
}
unset($updatedFields['company']);
}

parent::saveEntity($entity, $unlock);

if (!empty($company)) {
// Save after the lead in for new leads created through the API and maybe other places
$this->companyModel->addLeadToCompany($company['id'], $entity, true, true);
$this->companyModel->addLeadToCompany($company['id'], $entity, true);
}
}

Expand Down Expand Up @@ -721,7 +722,6 @@ public function getCurrentLead($returnTracking = false)
$this->logger->addDebug("LEAD: Existing lead found with ID# $leadId.");
}
}

$this->currentLead = $lead;
$this->setLeadCookie($leadId);
}
Expand Down