You are here

MappedEmailField.php in Pardot Integration 2.x

Namespace

Drupal\pardot

File

src/MappedEmailField.php
View source
<?php

namespace Drupal\pardot;


/**
 * Provides a class for mapped fields.
 */
class MappedEmailField extends MappedFieldBase {

  /**
   * {@inheritdoc}
   */
  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;
  }

  /**
   * {@inheritdoc}
   */
  public function setPluginType(string $plugin_type) {

    // We don't want this to change.
    // $this->pluginType = $plugin_type.
    return $this;
  }

}

Classes

Namesort descending Description
MappedEmailField Provides a class for mapped fields.