You are here

function patterns_utils_init_from_pattern in Patterns 7.2

Same name and namespace in other branches
  1. 7 includes/ \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


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/
Writes the pattern metadata (and the actual pattern) to the database.


includes/, line 152
Collectiion of general purpose functions.


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;