You are here

public function MappedEmailField::__construct in Pardot Integration 2.x

Constructs a new MappedField.

Parameters

string $pardot_key: The pardot field key to map the value to.

string $plugin_type: The plugin id.

mixed $plugin: (optional) The Plugin associated with this map.

mixed $config: (optional) Pass some initial config to the plugin.

Overrides MappedFieldBase::__construct

File

src/MappedEmailField.php, line 13

Class

MappedEmailField
Provides a class for mapped fields.

Namespace

Drupal\pardot

Code

public function __construct(string $pardot_key = '', string $plugin_type = 'default_value', $plugin = [], $config = []) {
  $this->pardotKey = $pardot_key;
  $this->pluginType = $plugin_type;
  if (!$plugin) {
    $plugin = \Drupal::service('plugin.manager.pardot_form_map_formatter_plugin')
      ->createInstance($this->pluginType);
  }
  if ($plugin) {
    $config += $plugin
      ->getConfiguration();
    $config['allowed_field_types'] = [
      'email',
    ];
    $plugin
      ->setConfiguration($config);
  }
  $this->plugin = $plugin;
}