You are here

function _commerce_bpc_get_value in Commerce Bulk Product Creation 7

Same name and namespace in other branches
  1. 7.2 commerce_bpc.module \_commerce_bpc_get_value()

Retrieve nested value in and array, providing a default.

This helper function allows to retrieve a nested value (of varying depth) from an array, providing a default in case the path does not exists.

@parram array $path Array of keys leading to the value to be retrieved. For example, to retrieve $array['settings']['storage'], $path should be array('settings', 'storage).

Parameters

array $array: The array from which to retrieve the value.

mixed $default: The value to return if the given path does not exist in $array.

Return value

mixed The value of the array at $path, or $default if this path does not exist.

7 calls to _commerce_bpc_get_value()
bpc_taxonomy_commerce_bpc_is_combination_field in modules/bpc_taxonomy/bpc_taxonomy.module
Implements hook_commerce_bpc_is_combination_field().
bpc_taxonomy_commerce_bpc_tokens in modules/bpc_taxonomy/bpc_taxonomy.module
Implements hook_commerce_bpc_tokens().
commerce_bpc_commerce_bpc_is_combination_field in ./commerce_bpc.hooks_list.inc
Implements hook_commerce_bpc_is_combination_field().
commerce_bpc_commerce_bpc_tokens in ./commerce_bpc.hooks_list.inc
Implements hook_commerce_bpc_tokens().
commerce_bpc_process_field_form_elements in ./commerce_bpc.forms.inc
Process the attached form elements.

... See full list

File

./commerce_bpc.module, line 523

Code

function _commerce_bpc_get_value($array, $path, $default) {
  $return = drupal_array_get_nested_value($array, $path, $key_exists);
  if (!$key_exists) {
    $return = $default;
  }
  return $return;
}