function field_test_entity_test_load
7.x field_test.entity.inc | field_test_entity_test_load($ftid, $ftvid = NULL) |
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.
9 calls to field_test_entity_test_load()
- FieldFormTestCase::testFieldFormAccess in drupal-7.x/
modules/ field/ tests/ field.test - Tests fields with no 'edit' access.
- FieldFormTestCase::testFieldFormSingle in drupal-7.x/
modules/ field/ tests/ field.test - FieldFormTestCase::testFieldFormSingleRequired in drupal-7.x/
modules/ field/ tests/ field.test - FieldFormTestCase::testFieldFormUnlimited in drupal-7.x/
modules/ field/ tests/ field.test - FieldTranslationsTestCase::checkTranslationRevisions in drupal-7.x/
modules/ field/ tests/ field.test - Check if the field translation attached to the entity revision identified by the passed arguments were correctly stored.
File
- drupal-7.x/
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];
}