You are here

function registration_get_entity_registration_type in Entity Registration 7.2

Same name and namespace in other branches
  1. 8.2 registration.module \registration_get_entity_registration_type()
  2. 8 registration.module \registration_get_entity_registration_type()
  3. 7 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.

8 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_get_registrations in ./registration.module
Load registrations for a host entity, optionally filtered to a particular registrant email.

... See full list

File

./registration.module, line 1367

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;
}