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,13 +3709,18 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function summaryFields() {
|
public function summaryFields() {
|
||||||
$fields = $this->stat('summary_fields');
|
$rawFields = $this->stat('summary_fields');
|
||||||
|
|
||||||
// if fields were passed in numeric array,
|
$fields = [];
|
||||||
// convert to an associative array
|
// Merge associative / numeric keys
|
||||||
if($fields && array_key_exists(0, $fields)) {
|
if (is_array($rawFields)) {
|
||||||
$fields = array_combine(array_values($fields), array_values($fields));
|
foreach ($rawFields as $key => $value) {
|
||||||
}
|
if (is_int($key)) {
|
||||||
|
$key = $value;
|
||||||
|
}
|
||||||
|
$fields[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$fields) {
|
if (!$fields) {
|
||||||
$fields = array();
|
$fields = array();
|
||||||
|
Loading…
Reference in New Issue
Block a user