Skip to content

Commit

Permalink
Merge pull request #7 from KonstantinCodes/feature/only-delete-new-leads
Browse files Browse the repository at this point in the history
Only remove newly created Leads
  • Loading branch information
KonstantinCodes authored May 30, 2018
2 parents 86702a7 + a37a878 commit 2866cd4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions EventListener/FormSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ public function onFormValidate(ValidationEvent $event)

$event->failedValidation("reCAPTCHA wasn't successful.");
$event->getDispatcher()->addListener(LeadEvents::LEAD_POST_SAVE, function (LeadEvent $event) {
/** @var LeadModel $model */
$model = $this->modelFactory->getModel(self::MODEL_NAME_KEY_LEAD);
$model->deleteEntity($event->getLead());
if ($event->isNew()){
/** @var LeadModel $model */
$model = $this->modelFactory->getModel(self::MODEL_NAME_KEY_LEAD);
$model->deleteEntity($event->getLead());
}
}, -255);
}
}

0 comments on commit 2866cd4

Please sign in to comment.