You are here

function inline_conditions_entity_metadata_field_property_get in Inline Conditions 7

Callback for getting field property values.

1 string reference to 'inline_conditions_entity_metadata_field_property_get'
inline_conditions_field_property_callback in ./inline_conditions.module
Property callback for IC module.

File

./inline_conditions.module, line 292
Extends Drupal 7 with a new field type to manage rules conditions directly from a field.

Code

function inline_conditions_entity_metadata_field_property_get($entity, array $options, $name, $entity_type, $info) {
  $field = field_info_field($name);
  $langcode = entity_metadata_field_get_language($entity_type, $entity, $field, isset($options['language']) ? $options['language']->language : LANGUAGE_NONE, TRUE);
  $values = array();
  if (isset($entity->{$name}[$langcode])) {
    foreach ($entity->{$name}[$langcode] as $delta => $rows) {
      $values[$delta] = $rows;
    }
  }

  // For an empty single-valued field, we have to return NULL.
  return $field['cardinality'] == 1 ? $values ? reset($values) : NULL : $values;
}