Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Commit

Permalink
RestrictionForm: Drop redundant properties..
Browse files Browse the repository at this point in the history
..while still retaining nested restrictions.

refs #3075
  • Loading branch information
Johannes Meyer committed May 22, 2016
1 parent 446f95b commit e189162
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,14 @@ public function getValues($suppressArrayNotation = false)
$values['exclude'] = array_map('trim', explode(',', $values['exclude']));
}

if ($this->restrictionMode === static::MODE_UPDATE) {
$currentState = $this->extract($this->data, $this->restrictionPath);
unset($currentState['include']);
unset($currentState['exclude']);
unset($currentState['permissions']);
$values = array_merge($currentState, $values);
}

$this->inject($this->data, $this->restrictionPath, $values);
}

Expand Down Expand Up @@ -473,11 +481,7 @@ protected function inject(array &$data, array $path, array $restriction)
if (! empty($path)) {
$this->inject($data[$key], $path, $restriction);
} elseif (is_numeric($key)) {
if (isset($data[$key])) {
$data[$key] = array_merge($data[$key], $restriction);
} else {
$data[$key] = $restriction;
}
$data[$key] = $restriction;
} else {
$data[$key][] = $restriction;
}
Expand Down

0 comments on commit e189162

Please sign in to comment.