You are here

function backup_migrate_crud_create_from_import in Backup and Migrate 8.3

Same name and namespace in other branches
  1. 6.3 includes/crud.inc \backup_migrate_crud_create_from_import()
  2. 7.3 includes/crud.inc \backup_migrate_crud_create_from_import()

Create an object from the exported object.

1 call to backup_migrate_crud_create_from_import()
backup_migrate_crud_import_form_validate in includes/crud.inc
Validate handler to import a view

File

includes/crud.inc, line 350
CRUD functions for backup and migrate types (schedules, profiles etc.).

Code

function backup_migrate_crud_create_from_import($code) {
  $item = NULL;
  $code = 'return ' . $code . ';';
  ob_start();
  $values = eval($code);
  ob_end_clean();
  if ($values) {
    if (!empty($values['type_name']) && ($type = backup_migrate_crud_type_load($values['type_name']))) {
      $item = $type
        ->create($values);

      // Make sure the item's ID doesn't already exist.
      $item
        ->unique_id();
    }
  }
  return $item;
}