You are here

function entityconnect_array_get_nested_value in Entity connect 7

Same name and namespace in other branches
  1. 7.2 includes/entityconnect.form.inc \entityconnect_array_get_nested_value()

Reimplements drupal_array_get_nested_value() to answer specific needs of the module.

Entityconnect button adds a new level in parents array, named "add_entityconnect" and "edit_entityconnect" and we need to remove them into our array building. So we need to rewrite drupal_array_set_nested_value() to include these remove.

See also

drupal_array_get_nested_value()

2 calls to entityconnect_array_get_nested_value()
entityconnect_add_edit_button_submit in includes/entityconnect.form.inc
Call when a new entity is to be added or edited.
entityconnect_return_form_alter in includes/entityconnect.form.inc
Complete entityreference field on parent form with the target_id value.

File

includes/entityconnect.form.inc, line 1052
Handles all form alters and submit functions for entityconnect.

Code

function &entityconnect_array_get_nested_value(array &$array, array $parents, &$key_exists = NULL) {
  $ref =& $array;
  foreach ($parents as $parent) {
    if (stripos($parent, 'add_entityconnect') === FALSE && stripos($parent, 'edit_entityconnect') === FALSE) {
      if (is_array($ref) && array_key_exists($parent, $ref)) {
        $ref =& $ref[$parent];
      }
      else {
        $key_exists = FALSE;
        $null = NULL;
        return $null;
      }
    }
  }
  $key_exists = TRUE;
  return $ref;
}