You are here

function finder_import in Finder 7.2

Same name and namespace in other branches
  1. 6 finder.module \finder_import()
  2. 7 finder.module \finder_import()

Export CRUD callback to import a finder.

A version of ctools_export_crud_import().

Parameters

$code: The string of import code.

1 string reference to 'finder_import'
finder_schema in ./finder.install
Implements hook_schema().

File

./finder.module, line 420
The finder module.

Code

function finder_import($code) {
  $schema = ctools_export_get_schema('finder');
  $export = $schema['export'];
  ob_start();
  eval($code);
  ob_end_clean();
  if (empty(${$export['identifier']})) {
    $errors = ob_get_contents();
    if (empty($errors)) {
      $errors = t('No item found.');
    }
    return $errors;
  }
  $item = ${$export['identifier']};

  // Set these defaults just the same way that ctools_export_new_object sets
  // them.
  $item->export_type = NULL;
  $item->{$export['export type string']} = t('Local');
  if (is_object($item)) {
    module_invoke_all('finder_import', $item);
  }
  return $item;
}