mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Back port 4.0 implementation of numeric/assoc key merging for summary_fields
This commit is contained in:
parent
f69f35eead
commit
e107512063
@ -3709,12 +3709,17 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return array
|
||||
*/
|
||||
public function summaryFields() {
|
||||
$fields = $this->stat('summary_fields');
|
||||
$rawFields = $this->stat('summary_fields');
|
||||
|
||||
// if fields were passed in numeric array,
|
||||
// convert to an associative array
|
||||
if($fields && array_key_exists(0, $fields)) {
|
||||
$fields = array_combine(array_values($fields), array_values($fields));
|
||||
$fields = [];
|
||||
// Merge associative / numeric keys
|
||||
if (is_array($rawFields)) {
|
||||
foreach ($rawFields as $key => $value) {
|
||||
if (is_int($key)) {
|
||||
$key = $value;
|
||||
}
|
||||
$fields[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fields) {
|
||||
|
Loading…
Reference in New Issue
Block a user