You are here

public function TMGMTLocalTaskItem::updateData in Translation Management Tool 7

Updates the values for a specific substructure in the data array.

The values are either set or updated but never deleted.

Parameters

$key: Key pointing to the item the values should be applied. The key can be either be an array containing the keys of a nested array hierarchy path or a string with '][' or '|' as delimiter.

$values: Nested array of values to set.

File

translators/tmgmt_local/entity/tmgmt_local.entity.task_item.inc, line 177

Class

TMGMTLocalTaskItem
Entity class for the local task item entity.

Code

public function updateData($key, $values = array()) {
  foreach ($values as $index => $value) {

    // In order to preserve existing values, we can not aplly the values array
    // at once. We need to apply each containing value on its own.
    // If $value is an array we need to advance the hierarchy level.
    if (is_array($value)) {
      $this
        ->updateData(array_merge(tmgmt_ensure_keys_array($key), array(
        $index,
      )), $value);
    }
    else {
      drupal_array_set_nested_value($this->data, array_merge(tmgmt_ensure_keys_array($key), array(
        $index,
      )), $value);
    }
  }
}