You are here

public function Token::getFormattedValue in Pardot Integration 2.x

Get the form field from the form state and apply formatting.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state that holds the input values.

Return value

mixed The formatted value or null i guess.

File

src/Plugin/PardotFormMapFormatterPlugin/Token.php, line 103

Class

Token
Plugin to generate a text field and consume tokens for mappings.

Namespace

Drupal\pardot\Plugin\PardotFormMapFormatterPlugin

Code

public function getFormattedValue(FormStateInterface $form_state) {
  $token = $this
    ->getConfiguration()['token'] ?? '';
  $entity_types = $this
    ->getConfiguration()['entity_types'] ?? [];
  $form_entity = $form_state
    ->getFormObject()
    ->getEntity();
  $replaced = $this->token
    ->replace($token, [
    $form_entity
      ->getEntityTypeId() => $form_entity,
  ]);
  if (empty($this->token
    ->scan($replaced))) {
    return $replaced;
  }
  return null;
}