function registration_get_entity_registration_type in Entity Registration 7
Same name and namespace in other branches
- 8.2 registration.module \registration_get_entity_registration_type()
- 8 registration.module \registration_get_entity_registration_type()
- 7.2 registration.module \registration_get_entity_registration_type()
Get the registration type bundle for a host entity.
Parameters
string $entity_type: The host entity type.
object $entity: The host entity.
Return value
string|bool Registration type associated with a host entity, or FALSE if none is associated.
7 calls to registration_get_entity_registration_type()
- RegistrationStandardTestCase::testRegistrationType in tests/
registration.test - Tests if registration type is set.
- registration_administer_registrations_access in ./
registration.module - Access callback: for registration_registrations_page().
- registration_entity_insert in ./
registration.module - Implements hook_entity_insert().
- registration_entity_update in ./
registration.module - Implements hook_entity_update().
- registration_register_page in ./
registration.module - Page callback: Add a new registration to a host entity.
File
- ./
registration.module, line 1356
Code
function registration_get_entity_registration_type($entity_type, $entity) {
$fields = field_read_fields(array(
'type' => 'registration',
));
foreach ($fields as $field) {
if (isset($entity->{$field['field_name']})) {
$items = field_get_items($entity_type, $entity, $field['field_name']);
// we're assuming there's only a single value in this field
if (!empty($items) && count($items) == 1 && !empty($items[0]['registration_type'])) {
return $items[0]['registration_type'];
}
}
}
return FALSE;
}