You are here

function commerce_registration_registrations_property_get in Commerce Registration 7.3

Entity getter callback to unserialize our registration property.

1 string reference to 'commerce_registration_registrations_property_get'
commerce_registration_entity_property_info_alter in ./commerce_registration.module
Implements hook_entity_property_info_alter().

File

./commerce_registration.module, line 210
Commerce Registration module code.

Code

function commerce_registration_registrations_property_get($data, array $options, $name, $type, $info) {
  $name = isset($info['schema field']) ? $info['schema field'] : $name;
  if ((is_array($data) || is_object($data) && $data instanceof ArrayAccess) && isset($data[$name])) {
    if (is_string($data[$name])) {
      return unserialize($data[$name]);
    }
    return $data[$name];
  }
  elseif (is_object($data) && isset($data->{$name})) {

    // Incorporate i18n_string translations. We may rely on the entity class
    // here as its usage is required by the i18n integration.
    if (isset($options['language']) && !empty($info['i18n string'])) {
      return $data
        ->getTranslation($name, $options['language']->language);
    }
    else {
      if (is_string($data->{$name})) {
        return unserialize($data->{$name});
      }
      return $data->{$name};
    }
  }
  return NULL;
}