improve customer api & gui

This commit is contained in:
Roland Schneider
2021-10-02 22:21:14 +02:00
parent 1d065cc729
commit f98dcb656f
44 changed files with 893 additions and 298 deletions

View File

@@ -0,0 +1,40 @@
<?php
namespace common\helpers;
class AppArrayHelper
{
public static function objectArrayToMap($array, $funcGetId, $funcGetValue){
$result = [];
foreach ($array as $item ){
$id = $funcGetId($item);
$value = $funcGetValue($item);
$result[$id] = $value;
}
return $result;
}
/**
* Map an array of object by object id
* [obj1,obj2] => [obj1.id => obj1,obj2.id => obj2]
* @param $array
* @return array
*/
public static function objectArrayToMapById($array){
return AppArrayHelper::objectArrayToMap(
$array,
function ($item){
return $item->id;
},
function ($item){
return $item;
}
);
}
}