- A lot of work done on bug fixing. Added a new SQLite adapter
This commit is contained in:
1 parent
667df92e52
commit
c14644cdda
28 files changed
+727
-234
No files matched your search
@@ -146,7 +146,12 @@ class EntityCollection extends \ArrayObject {
|
||||
return $this->filtersCollection(fn($obj) => is_a($obj, $className));
|
||||
}
|
||||
|
||||
public function column($field, bool $unique = false) : array
|
||||
public function column($field, bool $uniqueValue = false, $keyField = null) : array
|
||||
{
|
||||
return $this->map($field, $keyField, $uniqueValue);
|
||||
}
|
||||
|
||||
public function map($field, $keyField = null, bool $uniqueValue = false) : array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
@@ -158,11 +163,23 @@ class EntityCollection extends \ArrayObject {
|
||||
$value = $item->$field;
|
||||
}
|
||||
|
||||
if ($unique && in_array($value, $list, true)) {
|
||||
if ($uniqueValue && in_array($value, $list, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list[] = $value;
|
||||
if ( $keyField !== null ) {
|
||||
if ( is_callable($keyField) ) {
|
||||
$key = call_user_func_array($keyField, [ $item ]);
|
||||
}
|
||||
else {
|
||||
$key = $item->$keyField;
|
||||
}
|
||||
|
||||
$list[$key] = $value;
|
||||
}
|
||||
else {
|
||||
$list[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
||||
Reference in new issue
Block a user