1 field_test.entity.inc field_test_create_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $label = '')

Creates a basic test_entity entity.

File

core/modules/field/tests/field_test/field_test.entity.inc, line 212
Defines an entity type.

Code

function field_test_create_entity($id = 1, $vid = 1, $bundle = 'test_bundle', $label = '') {
  $entity = entity_create('test_entity', array());
  // Only set id and vid properties if they don't come as NULL (creation form).
  if (isset($id)) {
    $entity->ftid = $id;
  }
  if (isset($vid)) {
    $entity->ftvid = $vid;
  }
  $entity->fttype = $bundle;

  $label = !empty($label) ? $label : $bundle . ' label';
  $entity->ftlabel = $label;

  return $entity;
}