function patterns_utils_init_from_pattern in Patterns 7
Same name and namespace in other branches
- 7.2 includes/utils.inc \patterns_utils_init_from_pattern()
Take as input an array representing the pattern code or the pattern as extracted from the database and looks for the specified key.
In the following order returns:
- the $value parameter, if not NULL
- the value of the key if found in the INFO section
- the value of the key if found in the first level of the array
- NULL or $fallback if the key is not found
Parameters
mixed $key the key to look for:
array $patterm the array to inspect:
mixed $value a default value for the key:
mixes $fallback to return instead of NULL, if no key is found:
1 call to patterns_utils_init_from_pattern()
- patterns_db_save_pattern in includes/
db.inc - Writes the pattern metadata (and the actual pattern) to the database.
File
- includes/
utils.inc, line 152 - Collectiion of general purpose functions.
Code
function patterns_utils_init_from_pattern($key, $pattern, $value = NULL, $fallback = NULL) {
if (!is_null($value)) {
return $value;
}
if (isset($pattern['info'])) {
if (isset($pattern['info'][$key])) {
return $pattern['info'][$key];
}
}
if (isset($pattern[$key])) {
return $pattern[$key];
}
return $fallback;
}