function party_get_data_set_value in Party 7
Find a value from a property or field on a data set.
Parameters
Party $party: The party to find a value for.
string $data_set_name: The data set name we're pulling from.
string $column: The column to retrieve. This can be a column of a field or a property depending on whether $field_name was given.
string $field_name: (optional) A field name. If not provided, $column will be treated as a property of the entity.
Return value
The value retreived from the data set, or NULL if none was found.
File
- ./
party.module, line 1629 - Provides a generic CRM party entity.
Code
function party_get_data_set_value($party, $data_set_name, $column, $field_name = NULL) {
$controller = $party
->getDataSetController($data_set_name);
if ($entity = $controller
->getEntity()) {
if ($field_name) {
$items = field_get_items($controller
->getDataInfo('entity type'), $entity, $field_name);
if ($items) {
$item = reset($items);
return isset($item[$column]) ? $item[$column] : NULL;
}
else {
return NULL;
}
}
else {
return isset($entity->{$column}) ? $entity->{$column} : NULL;
}
}
}