You are here

function pdf_to_image_entity_save in PDF to ImageField 7.3

Stand-in for entity_save.

Why is there no entity_save in core? Stolen this from contrib entity.module.

Needed this to allow any entity, not just node to use these fields.

1 call to pdf_to_image_entity_save()
pdf_to_image_generate_process_attach in ./pdf_to_image.module
Attach generated files to the content entity (node) at the end of batch mode.

File

./pdf_to_image.module, line 661
Generates thumbnail image(s) from an uploaded PDF.

Code

function pdf_to_image_entity_save($entity_type, $entity) {
  $info = entity_get_info($entity_type);
  if (method_exists($entity, 'save')) {
    return $entity
      ->save();
  }
  elseif (isset($info['save callback'])) {
    $info['save callback']($entity);
  }
  elseif (in_array('EntityAPIControllerInterface', class_implements($info['controller class']))) {
    return entity_get_controller($entity_type)
      ->save($entity);
  }
  elseif (function_exists("{$entity_type}_save")) {
    $func = "{$entity_type}_save";
    return $func($entity);
  }
  return FALSE;
}