You are here

WebformMapping.php in Pardot Integration 2.x

File

src/Plugin/FormMapHandlerPlugin/WebformMapping.php
View source
<?php

namespace Drupal\pardot\Plugin\FormMapHandlerPlugin;

use Drupal\Core\Form\FormStateInterface;
use Drupal\pardot\FormMap;
use Drupal\pardot\Plugin\FormMapHandlerPluginBase;

/**
 * Plugin to capture browser cookies and send them to pardot.
 *
 * @FormMapHandlerPlugin(
 *  id = "webform_mapping",
 *  label = @Translation("Webform Mapping")
 * )
 */
class WebformMapping extends FormMapHandlerPluginBase {

  /**
   * {@inheritdoc}
   */
  public function getPluginId() {
    return 'webform_mapping';
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'entity_types' => [],
      'entity_type_id' => 'webform',
      'entity_id' => '',
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function getPluginDefinition() {
    return $this->pluginDefinition;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function injectRequiredFields(FormMap $pardot_form_map) {
    $pardot_form_map
      ->appendMappedField('\\Drupal\\pardot\\MappedEmailField', 'email', 'webform_submission_value', [], [
      'entity_id' => $this->configuration['entity_type_id'] . ':' . $this->configuration['entity_id'],
    ]);
  }

}

Classes

Namesort descending Description
WebformMapping Plugin to capture browser cookies and send them to pardot.