You are here

function fillpdf_context_to_link in FillPDF 7

Translates a FillPDF context array into a link.

Throws

\EntityMalformedException

4 calls to fillpdf_context_to_link()
FillPdfEntityTestCase::testEntityLink in tests/FillPdfEntityTestCase.test
Test fillpdf_context_to_link() and fillpdf_pdf_link() with entities.
FillPdfNodeTestCase::testNodeLink in tests/FillPdfNodeTestCase.test
Test fillpdf_context_to_link() with nodes.
FillPdfWebformTestCase::testWebformLink in tests/FillPdfWebformTestCase.test
Test fillpdf_context_to_link() with webforms.
fillpdf_update_7106 in ./fillpdf.install
Convert old JSON file contexts to the link-based format.

File

./fillpdf.module, line 451

Code

function fillpdf_context_to_link($fid, $context, $sample = FALSE) {
  $nids = NULL;
  if (!empty($context['nodes'])) {
    foreach ($context['nodes'] as $node) {
      $nids[] = $node->nid;
    }
  }
  $webforms = NULL;
  if (!empty($context['webforms'])) {
    foreach ($context['webforms'] as $webform) {
      $webforms[] = array(
        'nid' => $webform['webform']->nid,
        'sid' => $webform['submission']->sid,
      );
    }
  }
  $uc_orders = NULL;
  if (!empty($context['uc_orders'])) {
    foreach ($context['uc_orders'] as $uc_order) {
      $uc_orders[] = $uc_order->order_id;
    }
  }
  $uc_order_products = NULL;
  if (!empty($context['uc_order_products'])) {
    foreach ($context['uc_order_products'] as $uc_order_product) {
      $uc_orders[] = $uc_order_product->order_product_id;
    }
  }
  $entity_ids = NULL;
  if (!empty($context['entities'])) {
    foreach ($context['entities'] as $entity_type => $entities_by_type) {
      foreach ($entities_by_type as $entity) {
        list($id) = entity_extract_ids($entity_type, $entity);
        $entity_ids[] = $entity_type . ':' . $id;
      }
    }
  }
  return fillpdf_pdf_link($fid, $nids, $webforms, $sample, $uc_orders, $uc_order_products, $entity_ids);
}