function message_get_property_values in Message 7
Get the values of a message property.
The value of the message, after intersecting with the same values from the message-type. For example, it is possible to assign $message_type->arguments and $message->arguments. In case there are the same keys in the array, the $message will override the ones from the message-type.
Parameters
$message: The message object.
$name: The property name.
$key: Optional; If the property is an array, the key to be used to get the value.
$default_value: Optional; The default value to assign, if no value is given.
Return value
The merged values, or if no value if found and empty array.
1 call to message_get_property_values()
- Message::getText in includes/
message.message.inc - Replace arguments with their placeholders.
File
- ./
message.module, line 1010 - API functions to manipulate messages.
Code
function message_get_property_values(Message $message, $name, $key = NULL, $default_value = array()) {
$message_type = $message
->getType();
if (isset($key)) {
$type_value = isset($message_type->{$name}[$key]) ? $message_type->{$name}[$key] : array();
$value = isset($message->{$name}[$key]) ? $message->{$name}[$key] : array();
}
else {
$type_value = isset($message_type->{$name}) ? $message_type->{$name} : array();
$value = isset($message->{$name}) ? $message->{$name} : array();
}
if (isset($value) && !is_array($value)) {
// Value was found on the message.
return $value;
}
elseif (isset($type_value) && !is_array($type_value)) {
// Value was found on the message type.
return $type_value;
}
elseif (!empty($value) || !empty($type_value)) {
// Value was found in one of the entities, and it's an array, so merge.
return array_merge($type_value, $value);
}
// No value found, so return the default value.
return $default_value;
}