Loading modules/marketo_ma_webform/src/Plugin/WebformHandler/MarketoMaWebformHandler.php +18 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class MarketoMaWebformHandler extends WebformHandlerBase { 'formid' => '', 'marketo_ma_mapping' => [], 'marketo_ma_list' => '', 'program_name' => '', ]; } Loading Loading @@ -143,6 +144,13 @@ class MarketoMaWebformHandler extends WebformHandlerBase { '#default_value' => $this->configuration['marketo_ma_list'] ?? '', ]; $form['program_name'] = [ '#type' => 'textfield', '#title' => $this->t('Program Name'), '#description' => $this->t('Specify this to use Program Name'), '#default_value' => $this->configuration['program_name'] ?? '', ]; $form['marketo_ma_mapping'] = [ '#type' => 'webform_mapping', '#title' => $this->t('Webform to Marketo MA Lead mapping'), Loading Loading @@ -178,6 +186,16 @@ class MarketoMaWebformHandler extends WebformHandlerBase { '@form' => $this->getWebform()->label(), 'link' => $this->getWebform()->toLink($this->t('Edit'), 'handlers')->toString(), ]; // Set programName when sync lead. // @todo needs to check for correct program name if (isset($this->configuration['program_name']) && $this->configuration['program_name'] !== '') { $lead->setProgramName($this->configuration['program_name']); } else { $this->getLogger()->error('@form webform failed to find the Program Name', $context); } if (isset($this->configuration['formid'])) { $lead->setFormId($this->configuration['formid']); } Loading src/Lead.php +30 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,13 @@ class Lead { */ protected $formId; /** * Marketo program name. * * @var string */ protected $programName; /** * Marketo tracking cookie. * Loading Loading @@ -112,6 +119,16 @@ class Lead { return $this->formId; } /** * Get the program name if one is set. * * @return string|null * The program name that should be used during sync if set. */ public function getProgramName() { return $this->programName; } /** * Set a form ID. * Loading @@ -130,6 +147,19 @@ class Lead { return $this; } /** * Set a program name. * * @param string $programName * The program name. * * @return $this */ public function setProgramName($programName) { $this->programName = $programName; return $this; } /** * Get the current session "_mkto_trk" cookie value. * Loading src/Service/MarketoMaApiClient.php +1 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,7 @@ class MarketoMaApiClient implements MarketoMaApiClientInterface { public function syncLead(Lead $lead, $key = 'email'): ?int { $request = new PushLeadToMarketoRequest([ 'input' => [$this->mapLeadToRest($lead)], 'program_name' => $lead->getProgramName(), 'lookup_field' => $key, ]); $response = $this->leadsApi->pushToMarketoUsingPOST($request); Loading Loading
modules/marketo_ma_webform/src/Plugin/WebformHandler/MarketoMaWebformHandler.php +18 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,7 @@ class MarketoMaWebformHandler extends WebformHandlerBase { 'formid' => '', 'marketo_ma_mapping' => [], 'marketo_ma_list' => '', 'program_name' => '', ]; } Loading Loading @@ -143,6 +144,13 @@ class MarketoMaWebformHandler extends WebformHandlerBase { '#default_value' => $this->configuration['marketo_ma_list'] ?? '', ]; $form['program_name'] = [ '#type' => 'textfield', '#title' => $this->t('Program Name'), '#description' => $this->t('Specify this to use Program Name'), '#default_value' => $this->configuration['program_name'] ?? '', ]; $form['marketo_ma_mapping'] = [ '#type' => 'webform_mapping', '#title' => $this->t('Webform to Marketo MA Lead mapping'), Loading Loading @@ -178,6 +186,16 @@ class MarketoMaWebformHandler extends WebformHandlerBase { '@form' => $this->getWebform()->label(), 'link' => $this->getWebform()->toLink($this->t('Edit'), 'handlers')->toString(), ]; // Set programName when sync lead. // @todo needs to check for correct program name if (isset($this->configuration['program_name']) && $this->configuration['program_name'] !== '') { $lead->setProgramName($this->configuration['program_name']); } else { $this->getLogger()->error('@form webform failed to find the Program Name', $context); } if (isset($this->configuration['formid'])) { $lead->setFormId($this->configuration['formid']); } Loading
src/Lead.php +30 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,13 @@ class Lead { */ protected $formId; /** * Marketo program name. * * @var string */ protected $programName; /** * Marketo tracking cookie. * Loading Loading @@ -112,6 +119,16 @@ class Lead { return $this->formId; } /** * Get the program name if one is set. * * @return string|null * The program name that should be used during sync if set. */ public function getProgramName() { return $this->programName; } /** * Set a form ID. * Loading @@ -130,6 +147,19 @@ class Lead { return $this; } /** * Set a program name. * * @param string $programName * The program name. * * @return $this */ public function setProgramName($programName) { $this->programName = $programName; return $this; } /** * Get the current session "_mkto_trk" cookie value. * Loading
src/Service/MarketoMaApiClient.php +1 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,7 @@ class MarketoMaApiClient implements MarketoMaApiClientInterface { public function syncLead(Lead $lead, $key = 'email'): ?int { $request = new PushLeadToMarketoRequest([ 'input' => [$this->mapLeadToRest($lead)], 'program_name' => $lead->getProgramName(), 'lookup_field' => $key, ]); $response = $this->leadsApi->pushToMarketoUsingPOST($request); Loading