You are here

public function Serializer::importForm in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/Serializer.php \Drupal\fillpdf\Serializer::importForm()

Imports a FillPDF form..

Parameters

\Drupal\fillpdf\FillPdfFormInterface $fillpdf_form: The existing FillPDF form.

\Drupal\fillpdf\FillPdfFormInterface $imported_form: The FillPDF form being imported, usually from import code.

\Drupal\fillpdf\FillPdfFormFieldInterface[] $imported_fields: Array of FillPDF form objects to import.

Return value

string[] Array of unmatched PDF keys.

Overrides SerializerInterface::importForm

File

src/Serializer.php, line 84

Class

Serializer
Class Serializer.

Namespace

Drupal\fillpdf

Code

public function importForm(FillPdfFormInterface $fillpdf_form, FillPdfFormInterface $imported_form, array $imported_fields) {
  $properties_to_import = $imported_form
    ->getPropertiesToExport();
  foreach ($imported_form
    ->getFields() as $name => $data) {
    if (in_array($name, $properties_to_import, TRUE)) {
      $fillpdf_form->{$name} = $data;
    }
  }
  $fillpdf_form
    ->save();

  // Key the existing FillPDF fields on PDF keys.
  $existing_fields = $fillpdf_form
    ->getFormFields();
  $unmatched_pdf_keys = $this
    ->importFormFields($imported_fields, $existing_fields);
  return $unmatched_pdf_keys;
}