function field_test_entity_test_load

Loads a test_entity.

Parameters

$ftid: The id of the entity to load.

$ftvid: (Optional) The revision id of the entity to load. If not specified, the current revision will be used.

Return value

The loaded entity.

10 calls to field_test_entity_test_load()
FieldFormTestCase::testFieldFormAccess in drupal/modules/field/tests/field.test
Tests fields with no 'edit' access.
FieldFormTestCase::testFieldFormSingle in drupal/modules/field/tests/field.test
FieldFormTestCase::testFieldFormSingleRequired in drupal/modules/field/tests/field.test
FieldFormTestCase::testFieldFormUnlimited in drupal/modules/field/tests/field.test
FieldSqlStorageTestCase::testFieldSqlStorageMultipleConditionsDifferentColumnsMultipleLanguages in drupal/modules/field/modules/field_sql_storage/field_sql_storage.test
Test handling multiple conditions on multiple columns of one field for multiple languages.

... See full list

File

drupal/modules/field/tests/field_test.entity.inc, line 244
Defines an entity type.

Code

function field_test_entity_test_load($ftid, $ftvid = NULL) {

  // Load basic strucure.
  $query = db_select('test_entity', 'fte', array())
    ->condition('fte.ftid', $ftid);
  if ($ftvid) {
    $query
      ->join('test_entity_revision', 'fter', 'fte.ftid = fter.ftid');
    $query
      ->addField('fte', 'ftid');
    $query
      ->addField('fte', 'fttype');
    $query
      ->addField('fter', 'ftvid');
    $query
      ->condition('fter.ftvid', $ftvid);
  }
  else {
    $query
      ->fields('fte');
  }
  $entities = $query
    ->execute()
    ->fetchAllAssoc('ftid');

  // Attach fields.
  if ($ftvid) {
    field_attach_load_revision('test_entity', $entities);
  }
  else {
    field_attach_load('test_entity', $entities);
  }
  return $entities[$ftid];
}