You are here

function registration_get_properties in Entity Registration 7

Same name and namespace in other branches
  1. 8 registration.module \registration_get_properties()

Required by RegistrationMetadataController for Views integration.

Parameters

$entity:

array $options:

$name:

$type:

Return value

EntityMetadataWrapper

1 string reference to 'registration_get_properties'
RegistrationMetadataController::entityPropertyInfo in lib/registration.metadata.inc

File

./registration.module, line 1815

Code

function registration_get_properties($entity, array $options, $name, $type) {
  switch ($name) {
    case 'anon_mail':
      return $entity->anon_mail;
      break;
    case 'anon_access_hash':
      return registration_anonymous_access_hash($entity);
      break;
    case 'anon_link':

      // Create a link that can be used to access an anonymously created event from anywhere.
      $path = entity_uri('registration', $entity);
      $url = url($path['path'] . '/view/' . registration_anonymous_access_hash($entity), array(
        'absolute' => TRUE,
      ));
      return $url;
      break;
    case 'entity':
      return entity_metadata_wrapper($entity->entity_type, $entity->entity);
      break;
    case 'mail':

      // If a user is set, use their email
      $user = entity_metadata_wrapper('registration', $entity)->user;
      return $user
        ->value() ? $user->mail
        ->value() : $entity->anon_mail;
      break;
  }
}