You are here

protected function FillPdfTestHelper::mapFillPdfFieldsToEntityFields in FillPDF 7

Maps FillPDF fields to entity fields.

Parameters

string $entity_type: The entity type.

array $fields: Associative array of PDF fields.

int $fid: ID of the FillPDF form.

2 calls to FillPdfTestHelper::mapFillPdfFieldsToEntityFields()
FillPdfMergeTestCase::backendTest in tests/FillPdfMergeTestCase.test
Tests PDF merging.
FillPdfMergeTestCase::testPdfMerging in tests/FillPdfMergeTestCase.test
Test PDF merging.

File

tests/FillPdfTestHelper.test, line 211

Class

FillPdfTestHelper
Helper functions for FillPDF testing.

Code

protected function mapFillPdfFieldsToEntityFields($entity_type, array $fields, $fid) {
  $info = entity_get_info($entity_type);
  $token_type = $info['token type'];
  $label_key = $info['entity keys']['label'];
  $image_field_map = array(
    'node' => '[node:field_test_image]',
    'taxonomy_term' => '[term:field_term_image]',
    'user' => '[user:picture]',
  );
  foreach ($fields as $pdf_key => $field) {
    if ($pdf_key == 'ImageField') {
      if (isset($image_field_map[$entity_type])) {
        $field['value'] = $image_field_map[$entity_type];
      }
    }
    elseif ($pdf_key == 'TextField') {
      $field['value'] .= "[{$token_type}:{$label_key}]";
    }
    else {
      continue;
    }
    fillpdf_fields_create_update($fid, $pdf_key, $field, TRUE);
  }
}