ContactFormMapping.php in Pardot Integration 2.x
File
src/Plugin/FormMapHandlerPlugin/ContactFormMapping.php
View source
<?php
namespace Drupal\pardot\Plugin\FormMapHandlerPlugin;
use Drupal\Core\Form\FormStateInterface;
use Drupal\pardot\FormMap;
use Drupal\pardot\Plugin\FormMapHandlerPluginBase;
class ContactFormMapping extends FormMapHandlerPluginBase {
public function getPluginId() {
return 'contact_form_mapping';
}
public function defaultConfiguration() {
$entity_types = [
'contact_message',
];
$entity_type_id = 'contact_form';
$default_values = [
'entity_types' => $entity_types,
'entity_type_id' => $entity_type_id,
'entity_id' => '',
] + parent::defaultConfiguration();
return $default_values;
}
public function getPluginDefinition() {
return $this->pluginDefinition;
}
public function buildConfigurationForm($form, FormStateInterface $form_state) {
return parent::buildConfigurationForm($form, $form_state);
}
public function injectRequiredFields($pardot_form_map) {
$pardot_form_map
->appendMappedField('\\Drupal\\pardot\\MappedEmailField', 'email', '', [], [
'entity_id' => $this->configuration['entity_type_id'] . ':' . $this->configuration['entity_id'],
]);
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
}
}